import Cocoa
//打印信息
println("Hello, Swift")
//变量与常量
//使用var声明变量,let声明常量
var myVariable = 42
myVariable = 50
let myConstant = 42
//类型推导(Type Inference)
let explicitDouble : Double = 70
//不支持隐式类型转换(Implicitly casting),所以下面的代码需要显式类型转换(Explicitly castrng),也就是说必须进行强制类型转换
let label = "The width is "
let width = 94
let widthLabel = label + String(width)
//字符串格式化,使用\(item)的形式进行字符串格式化:
let apples = 3
let oranges = 5
let appleSummary = "I have \(apples) apples."
let fruitSummary = "I have \(apples + oranges) pieces of fruit."
//数组和字典,使用[]声明数组(array)和字典(dictionary)
var shoppingList = ["catfish", "water", "tulips", "blue paint"]
shoppingList[1] = "bottle of water"
var occupations = [
"Malcolm":"Captain",
"Kaylee":"Mechanic",
]
occupations["Jayne"] = "Public Relations"
//一般使用初始化器(initializer)语法创建空数组和空字典
let emptyArray = String[]()
let emptyDictionary = Dictionary<String, Float>()