Is there a quick way to remove the last two characters in a String in Swift? I see there is a simple way to remove the last character as clearly noted here. Do you know ho
Use removeSubrange(Range) just like:
removeSubrange(Range)
var str = "Hello, playground" str.removeSubrange(Range(uncheckedBounds: (lower: str.index(str.endIndex, offsetBy: -2), upper: str.endIndex)))
This will crash if the string is less than 2 characters long. Is that a requirement for you?