[code]
//
// main.swift
// t1
//
// Created by liu qing on 15/9/13.
// Copyright (c) 2015年 liu qing. All rights reserved.
//
import Foundation
//println("Hello, World!") //output function
var a:Int=42 //变量
let b:Double=12 //常量
//变量和常量一定要初始化
//println(b)
var π:Double = 3.14 //按键option+p输出π
var 你好 = "也行"
let ="旺旺"
//println(π)
//println(你好)
//println()
let int1 = UInt8.min
let int2 = UInt8.max
let int3 = 0o21 //8进制
let int4 = 0x11
//println(int1,b)
//类型别名
typealias cool = Int
var t1:cool = 45
t1 = 10
//println(t1)
//array
var t2 = []
var ea:Array = [Int]()
var t3 = ["1","b"]
t3.append("sdf")
t3.insert("qwe", atIndex:1);
println(t3[0])
//dictionay
var t4 = [:]
var t5 = Dictionary
t5 = ["a":"123","b":"er"]
t5["c"]="occ 123"
println(t5);
t5["a"] = nil
println(t5);
t5.removeValueForKey("b")
println(t5);
println("count:"+String(t5.count));
for(key,value) in t5 {
println("\(key):\(value)")
}
for key in t5.keys{
println(key)
}
for value in t5.values{
println(value)
}
let allkeys = Array(t5.keys) //把所有的key转换成数组
let allvalues = Array(t5.values) //把所有的values转换成数组
println(allkeys,allvalues)
[/code]