我很擅长快速编码< 1年......所以,我接受我需要帮助......在这个练习中弹出一条错误信息,说'预期':'案例后'
我的代码在这里:
let Temperature = 65
switch Temperature {
case Int.min <.. 65:
print(“the temperature is too low”)
case 65...75:
print(“the temperature is perfect”)
case 75>..Int.max:
print(“the temperature is too high”)
default:
print (“please set a temperature value”)
答案 0 :(得分:1)
请注意,没有<..
,>..
或..>
等字段,您只能使用CountableClosedRange ...
或CountableRange {{ 1}}如果您在Swift 4或更高版本中进行编码,则无需使用Int.min或Int.max,您可以简单地省略它并使用部分范围运算符。
..<
如果您使用的是Swift 3或更早版本,则可以执行以下操作:
switch Temperature {
case ..<65:
print("the temperature is too low")
case 65...75:
print("the temperature is perfect")
case 75...:
print("the temperature is too high")
default:
break
}