Files
2016-10-11 15:43:13 +03:00

16 lines
445 B
Swift
Executable File

import Foundation
extension String {
subscript (i: Int) -> Character {
let index = self.index(self.startIndex, offsetBy: i)
return self.characters[index]
}
func substring(from: Int, to: Int) -> String {
let fromIndex = self.index(self.startIndex, offsetBy: from)
let toIndex = self.index(self.startIndex, offsetBy: to + 1)
return self.substring(with: fromIndex ..< toIndex)
}
}