为什么会出现错误,无法调用类型为((Range)'的参数列表的类型为'Range <_>'的初始化程序
extension String {
subscript (i: Int) -> Character {
if self.isEmpty {
return Character("")
}
if i > self.characters.count {
return Character("")
}
return self[self.index(self.startIndex, offsetBy: i)]
}
subscript (i: Int) -> String {
if self.isEmpty {
return ""
}
if i > self.characters.count {
return ""
}
return String(self[i] as Character)
}
subscript (r: Range<Int>) -> String {
let start = self.index(self.startIndex, offsetBy: r.lowerBound)
let end = self.index(start, offsetBy: r.upperBound - r.lowerBound)
return self[Range(start ..< end)]
}
}