subscript (r: Range<Int>) -> String {
let start = startIndex.advancedBy(r.startIndex)
let end = start.advancedBy(r.endIndex - r.startIndex)
return self[Range(start: start, end: end)]
}
Struggling to convert the above subscript in my String extension to swift 3. Below is what happened after I pressed the convert button on Xcode.
subscript (r: Range<Int>) -> String {
let start = characters.index(startIndex, offsetBy: r.lowerBound)
let end = <#T##String.CharacterView corresponding to `start`##String.CharacterView#>.index(start, offsetBy: r.upperBound - r.lowerBound)
return self[(start ..< end)]
}
Screenshot of error