摘要:
定义 形参默认是let,也只能是let func sum(v1: Int, v2: Int) -> Int { return v1 + v2 } sum(v1: 10, v2: 20) // 无返回值 func sayHello() -> Void { print("Hello") } func s 阅读全文
摘要:
if-slse let age = 4 if age >= 22 { print("Get married") } else if age >= 18 { print("Being a adult") } else if age >= 7 { print("Go to school") } else 阅读全文
摘要:
Hello World print("Hello World") 不用编写main函数,Swift将全局范围内的首句可执行代码作为程序入口一句代码尾部可以省略分号(;),多句代码写到同一行时必须用分号(;)隔开 用var定义变量,let定义常量,编译器能自动推断出变量\常量的类型 Playgroun 阅读全文