Swift基础数据类型学习

//-----------------------------------------------------------

//常量

let age = 25 * 4

//变量

var name = "zhangsan"

name = "张三" + "hhh"

print("姓名:\(name),年龄:\(age)")

//定义多个常量

let number = "123456", score = 70, address = "徐汇区零陵路"

//定义多个变量

var height = 168, sex = "男", weight = 55

height = 166

weight = 54

print("姓名:\(name),性别:\(sex),年龄:\(age),身高:\(height),体重:\(weight)KG,学号:\(number),成绩:\(score),地址:\(address)")

//类型标注------------------------------------------------------

//常量类型标注

let name2 : String = "李四"

//变量类型标注

var name3 : String = ""

name3 = "李小四"

print("常量标注==\(name2),变量标注==\(name3)")

//32位整数范围

print("\(UInt32.min)<32位整数范围<\(UInt32.max)")

//8位整数范围

print("\(UInt8.min)<32位整数范围<\(UInt8.max)")

//类型别名--------------------------------------------------------

typealias ZhangSan = String

var name4 : ZhangSan = "张三"

var tempName = name4 + "李四"

print("name4==\(name4),tempName==\(tempName)")

你可能感兴趣的:(Swift基础数据类型学习)