Created
February 24, 2016 00:42
-
-
Save makthrow/a1593ad53b9e10ab1e4c 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
import Foundation | |
var s = "hello" | |
s.startIndex // starts at 0 | |
let index = s.startIndex.advancedBy(2) // index is a String.index to the 3rd glyph, "l" | |
print (index) | |
s.insertContentsOf("abc".characters, at: index) | |
let startIndexPlusOne = s.startIndex.advancedBy(1) // advance s.startIndex from 0 to 1 | |
let endIndex = s.startIndex.advancedBy(6) // advance s.startIndex from 0 to 6 | |
let substring = s[index..<endIndex] // "abcl" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment