更新时间:2022-06-22 22:26:31
Range.init(start:end:)
构造函数在 Swift 3.0 中被移除,所以你可以像下面这样初始化一个范围:
Range.init(start:end:)
constructor was removed in Swift 3.0 so you initialize a range like follows:
let range = hex.index(hex.startIndex, offsetBy: 2)..<hex.index(hex.startIndex, offsetBy: 4)
它返回一个 half-open 类型的
范围.然后,您可以使用它执行以下操作:
which returns a half-open range of type <String.Index>
. Then, you can do the following with that:
hex.substring(with: range)