Created
November 8, 2017 23:10
-
-
Save josephchang10/5c3a221fe67c86a983c0dfc43bc3469e to your computer and use it in GitHub Desktop.
The more elegant way to remove all characters after specific character in the String object in Swift
This file contains 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
var str = "str.str" | |
if let dotRange = str.range(of: ".") { | |
str.removeSubrange(dotRange.lowerBound..<str.endIndex) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment