//: Playground - noun: a place where people can play
import UIKit
var rating = "A"
// if - else if
if rating == "A" {
print("Very Good!!");
} else if rating == "B"{
print("Just So-So")
} else {
print("It's too bad!!")
}
// switch
// 和其他语言不同, 这里的switch不需要写break
// 还有就是可以判断的类型更多了
rating = "C"
switch rating
{
case "A", "a": // 进行多个值的判断
print("Very Good!!")
case "B":
print("Just So-So")
default: // default是必须要有的
print("It's too bad!!")
}
// 判断字符串类型
switch rating
{
case "I'm String":
print("I'm String")
default:
print("I'm not String")
}
// 判断Bool类型
var imBool = true
switch imBool
{
case true:
print("true")
default:
print("false")
}
// 判断Float类型
var imFloat = 2.8
switch imFloat
{
case 2.0:
print("2.0")
default:
print("\(imFloat)")
}