Created
October 17, 2016 11:51
-
-
Save dfelber/45544c93e90e371acca1a03ee9373861 to your computer and use it in GitHub Desktop.
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
extension String { | |
subscript (i: Int) -> Character { | |
return self[self.startIndex.advancedBy(i)] | |
} | |
subscript (i: Int) -> String { | |
return String(self[i] as Character) | |
} | |
subscript (r: Range<Int>) -> String { | |
let start = startIndex.advancedBy(r.startIndex) | |
let end = start.advancedBy(r.endIndex - r.startIndex) | |
return self[Range(start ..< end)] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment