Created
January 4, 2016 10:21
-
-
Save ericdke/0d730e556ac30ccf6c46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension String { | |
| var isNumeric: Bool { | |
| let nums: Set<Character> = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] | |
| return Set(self.characters).isSubsetOf(nums) | |
| } | |
| } | |
| "No numbers here".isNumeric // false | |
| "123".isNumeric // true | |
| "Hello world 123".isNumeric // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment