println("Hello, World!")
var str = "Hello, playground"
let valne = "Hello, world"
let expDouble:Double = 70
//let text = valne + String(expDouble)//快速字符转化,注意转化值被显式指定后无法使用此方法
//println(text)
println(str + valne + " \(expDouble)")//快速字符转化
var textArray = ["hello","goog","eeeee"]//快速数组
let text = textArray[1]
println(text)
var textDict = [
"MAX":"Good",//左key右值
"TEST":"Hello"
]
println([textDict["MAX"]])
//四种空数组的创建,使用方式未知
let emptyArray = [String]()
let emptyDict = [String:Float]()
var shoppingList = []
var occupatios = [:]
var optionalString:String? = "Hello"
optionalString == nil
var optionalName: String? = "John"
optionalName = nil
var greeting = "Hello!"
if let name = optionalName{
greeting = "Hello,\(name)"
}else{
greeting = "nil"
}
let vegetable = "red pepper"
switch vegetable{
case "celery":
let vage = "aaaaaaaaaaaa"
case let x where x.hasSuffix("pepper"):
let va = "sssssaaa"
default:
let vae = "eEEEEEEEEE"
}
var n = 2
while n < 100{
n *= 2
}
n
var m = 2
do{
m *= 2
}while m < 100
m |
|