import UIKit
enumPerson
{
casezhangsan
caselisi
casewangwu
}
enumPerson2
{
casezhangsan,lisi,wangwu
}
enumMethod
{
caseAdd
caseSub
caseMul
caseDiv
}
letp = Person.zhangsan
letp2 = Person2.lisi
enumMethod1 :Int
{
caseAdd =1
caseSub =2
caseMul =3
caseDiv =4
}
enumMethod2 :Double
{
caseAdd =1.0
caseSub =2.0
caseMul =3.0
caseDiv =4.0
}
enumMethod3 :String
{
caseAdd ="1.0"
caseSub ="2.0"
caseMul ="3.0"
caseDiv ="4.0"
}
letmethod = Method.Div
switchmethod {
case.Add:
print("Add")
case.Sub:
print("Sub")
case. Mul:
print("Mul")
case. Div:
print("Div")
default:
print("default")
}
网友评论