【发布时间】:2014-09-29 16:02:15
【问题描述】:
有这样的代码:
switch (indexPath.section, indexPath.row) {
case (0, 1...5): println("in range")
default: println("not at all")
}
问题是我可以在第二个元组值中使用多个区间吗?
对于非元组切换,它可以很容易地完成,就像
switch indexPath.section {
case 0:
switch indexPath.row {
case 1...5, 8...10, 30...33: println("in range")
default: println("not at all")
}
default: println("wrong section \(indexPath.section)")
}
我应该使用哪个分隔符来分隔元组内的间隔,否则它不适用于元组开关,我必须在开关内使用开关?谢谢!
【问题讨论】:
标签: ios swift switch-statement tuples xcode6