//: Playground - noun: a place where people can play
import UIKit
//整数类型
let int_a =10
let int_b :Int
let int_c :Int = 10
//注意不能 let int_c (即是在定义常量或者变量时,在隐示声明的时候必须初始化)
//字符串
let string_a ="i like eat"
let string_b:String
let string_c:String = "i like eat"
//类型强制转换
let apple ="the number of apple is "
let number =10
let number_apple=apple + String(number)
print("the number is\(number)")
// 浮点数
let float_a =1.0
let float_b:Float
let float_c:Float=1.0
let double_a =1.99
let double_b:Double
let double_c:Double=1.99
//布尔类型
let bool_a=true
let bool_b=false
let bool_c:Bool
let bool_d:Bool=true
//数组与字典
let emptyArray = [String]()
var array1 = ["aa","bb",12]
let emptyDictionary =Dictionary<String,Float>()
var dictionary1 = ["xiaoming":10,"xiaohong":12]
dictionary1["xiaofei"] = 12//添加元素
import UIKit
//整数类型
let int_a =10
let int_b :Int
let int_c :Int = 10
//注意不能 let int_c (即是在定义常量或者变量时,在隐示声明的时候必须初始化)
//字符串
let string_a ="i like eat"
let string_b:String
let string_c:String = "i like eat"
//类型强制转换
let apple ="the number of apple is "
let number =10
let number_apple=apple + String(number)
print("the number is\(number)")
// 浮点数
let float_a =1.0
let float_b:Float
let float_c:Float=1.0
let double_a =1.99
let double_b:Double
let double_c:Double=1.99
//布尔类型
let bool_a=true
let bool_b=false
let bool_c:Bool
let bool_d:Bool=true
//数组与字典
let emptyArray = [String]()
var array1 = ["aa","bb",12]
let emptyDictionary =Dictionary<String,Float>()
var dictionary1 = ["xiaoming":10,"xiaohong":12]
dictionary1["xiaofei"] = 12//添加元素
print(dictionary1)
//枚举
enum Person{
case 小明
case 小红
case 小花
}
let person1:Person = .小明
let person2:Person = .小红
let person3:Person = .小花
let person:Person = person2
switch person{
case .小明:
print("是小明")
case .小红:
print("是小红")
case .小花:
print("是小花")
}