我是Swift的新手,正在Swift Playgrounds中进行测试。尝试使用switch
,但不起作用。有人可以帮我吗?
func loveCal() {
let loveScore = Int.random(in: 0...100)
switch loveScore {
case 80...100:
print("You love eachother like Kanye loves Kanye")
case 40...80:
print("You go together like coke and mentos")
case 0...40:
print("You'll be forever alone")
}
}
loveCal()
我是Swift的新手,正在Swift Playgrounds中进行测试。尝试使用开关,但不起作用。有人能帮我吗? func loveCal(){let loveScore = Int.random(in:0 ... 100)...
您所缺少的只是default
例: