let name = "经纪人"
/**
* 1.值可以是任何类型
* 2.作用域,仅在case内部
* 3.不需要 break
* 4.每一个case内必须要有代码
*/
switch name{
case "老王":
let age = 80
print("HI")
case "经纪人":
print("老朋友")
default:
print("other")
}
let name = "经纪人"
/**
* 1.值可以是任何类型
* 2.作用域,仅在case内部
* 3.不需要 break
* 4.每一个case内必须要有代码
*/
switch name{
case "老王":
let age = 80
print("HI")
case "经纪人":
print("老朋友")
default:
print("other")
}
本文标题:Switch
本文链接:https://www.haomeiwen.com/subject/djrzettx.html
网友评论