let text = "123"
print(text)
print(text.substringToIndex(text.startIndex.successor()))//把原先的开区间变成闭区间
print(text.substringFromIndex(text.startIndex.successor()))//把原先的闭区间变成开区间
输出结果:
123
1
23
=============================================
let text = "123"
print(text)
print(text.substringToIndex(text.startIndex))//to方法本身就是开区间
print(text.substringFromIndex(text.startIndex))//from方法本身就是闭区间
输出结果:
123
(注意此处为空)
123