📅  最后修改于: 2022-03-11 14:56:04.005000             🧑  作者: Mango
//swift 4-5
let text = "abc"
let index2 = text.index(text.startIndex, offsetBy: 2) //will call succ 2 times
let lastChar: Character = text[index2] //now we can index!
let characterIndex2 = text.index(text.startIndex, offsetBy: 2)
let lastChar2 = text[characterIndex2] //will do the same as above
let range: Range = text.range(of: "b")!
let index: Int = text.distance(from: text.startIndex, to: range.lowerBound)