是否可能创建一个反向的Range
?
我的意思是从99到1,而不是反过来。我的目标是迭代从99到1的值。
这个代码无法编译,但它应该能给你一个我想做什么的想法:
for i in 99...1{
print("\(i) bottles of beer on the wall, \(i) bottles of beer.")
print("Take one down and pass it around, \(i-1) bottles of beer on the wall.")
}
在Swift
中,最简单的实现方式是什么?