//变量var str = "Hello, playground"var dd = 23var PI = 3.14var uu = truevar me = ("me",11,"33")
me.0
me.1
me.2
PI = 3.12
2.常量
//常量let m = 89let u = falsevar a:Int
var b:String
print(a) //a 还没有初始化,不能使用
3.int、float、double
Int.min//-9223372036854775808
Int.max//9223372036854775807
Int64.min//-9223372036854775808
Int64.max//9223372036854775807let f =15//15let fa =0xF//15let fb =0o17 //15let fc =0b1111 //15let fd =1_000_000 //1000000var oneThirdint =1/3//默认类型int,0var oneThirdFloat:Float =1/3//小数点后有7位,0.3333333var oneThirdDouble:Double =1/3//小数点后有16位,0.3333333333333333
print(oneThirdint) //0\n
print(oneThirdFloat) //由打印可知,精确度为小数点后6位,0.333333\n
print(oneThirdDouble) //精确度为小数点后15位,0.333333333333333\n
4.查看推导类型type(of:XXX)
var three = 3
type(of:three) //查看推导结果,Int.Type
var z = 0.14
type(of:z) //Double.Type
var PI = 314e-2 //3.14PI = 3 + 0.14159 //3.14159PI = Double(three) + z // 不同类型变量不能直接加减,要先类型转换,3.14