Last active
June 1, 2017 23:46
-
-
Save efremidze/1fa1985632d502b09bb6a4e3752c4f22 to your computer and use it in GitHub Desktop.
String character count (more accurate)
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 count: Int { | |
var length = 0 | |
enumerateSubstrings(in: startIndex..<endIndex, options: .byComposedCharacterSequences) { substring, substringRange, enclosingRange, stop in | |
length += 1 | |
} | |
return length | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment