以数组举例
//最近迷上了吃鸡。
var nameArray = ["手枪","散弹枪","冲锋枪","步枪","狙击枪"]
//闭区间运算符 输出 "散弹枪","冲锋枪","步枪","狙击枪"
for name in nameArray[1...4] {
print(name)
}
//半开区间运算符 输出 "散弹枪","冲锋枪","步枪"
for name in nameArray[1..<4] {
print(name)
}
//单侧区间 输出 "冲锋枪","步枪","狙击枪"
for name in nameArray[2...] {
print(name)
}
//输出 "手枪","散弹枪","冲锋枪"
for name in nameArray[...2] {
print(name)
}