1.变量
var str = "Hello,playground"
var dd = 23
var PI = 3.14
var uu = true
var me = ("me",11,"33")
me.0
me.1
me.2
PI = 3.12
2.常量
let m = 89
let u = false
var a:Int
var b:String
print(a)
3.int、float、double
Int.min
Int.max
Int64.min
Int64.max
let f = 15
let fa = 0xF
let fb = 0o17
let fc = 0b1111
let fd = 1_000_000
var oneThirdint = 1/3
var oneThirdFloat:Float = 1/3
var oneThirdDouble:Double = 1/3
print(oneThirdint)
print(oneThirdFloat)
print(oneThirdDouble)
4.查看推导类型type(of:XXX)
var three = 3
type(of:three)
var z = 0.14
type(of:z)
var PI = 314e-2
PI = 3 + 0.14159
PI = Double(three) + z
原文链接:https://www.f2er.com/swift/322190.html