String Indexing
Use String.Index with startIndex, index(_:offsetBy:) or convert to an Array.
Example
let s = "Swift"
let i = s.index(s.startIndex, offsetBy: 2)
print(s[i])
print(s[s.startIndex])
print(Array(s)[4])
print(s.prefix(3), s.suffix(2))Exercise
Move an index.
s.index(s.startIndex, : 2)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.