changjiashuai's blog

Runnig...

The future belongs to those who believe in the beauty of their dreams.


Swift基础---Booleans

初始化

let orangesAreOrange = true
let turnipsAreDelicious = false

使用

if turnipsAreDelicious {
  println("Mmm, tasty turnips!")
}else{
  println("Eww, turnips are horrible.")
}


let i = 1
if i {
  // ---error
}

if i== 1 {
  // ---successfully
}
最近的文章

Swift基础---Integers

integers提供了三种(8, 16, 32) signed unsigned IntInteger Boundslet minValue = UInt8.min //0let maxValue = UInt8.max //255Intlet intValue = 42Doublelet pi = 3.14159let anotherPi = 3 + 0.14159进制let decimalInteger = 17 //十进制let binaryInteger ...…

继续阅读
更早的文章

Swift基础---常量、变量

常量声明 (不可变)let constants = 10constants = 20 ----> error 变量声明 (可变)var x = 0var a = 1, b = 2, c = 3x = 10 注释类型声明(Type Annotations)var welcomeMessage: String 任何字符都可以作为变量、常量名let π = 3.14159let 你好 = "你好世界"let 🐶🐮 = "dogcow” 输出常量、变量println(x)prin...…

继续阅读