Skip to content

Instantly share code, notes, and snippets.

@Bashta
Created December 10, 2015 13:33
Show Gist options
  • Select an option

  • Save Bashta/4780f50fdb04688eda33 to your computer and use it in GitHub Desktop.

Select an option

Save Bashta/4780f50fdb04688eda33 to your computer and use it in GitHub Desktop.
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 {
return substringWithRange(Range(start: startIndex.advancedBy(r.startIndex), end: startIndex.advancedBy(r.endIndex)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment