区间运算符

2020-09-14  本文已影响0人  黑白森林无间道

闭区间运算符

半开区间运算符

单侧区间

字符串索引区间

倒叙索引

Comparable区间

let names = ["zhangsan", "lisi", "wangwu", "zhaoliu"]
for name in names[..<2] {
    print(name)
}

let range = ...5
range.contains(7)
range.contains(4)
range.contains(-100)

var welcome = "hello,world"
let subRange = welcome.index(welcome.endIndex, offsetBy: -6)..<welcome.endIndex
welcome.removeSubrange(subRange)
print(welcome)
上一篇下一篇

猜你喜欢

热点阅读