A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© weizhang00 中级黑马   /  2014-11-20 23:40  /  757 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马