Strings In Depth17 / 18
Up next

Offset an index

let s = "swift"
// step an index forward by a count
let i = s.index(s.startIndex, offsetBy: 2)
print(s[i])
// slice from that index to the end
print(s[i...])
What you're solving

index(_:offsetBy:)