看了下Doc這語言可能會幫助開發者更快速地開發Apple的產品,只是希望這產品不會到最後變成孤兒..
let:用於宣告常數
var:用於宣告變數
for:用法則有點類似JavaScript
for in:用法有點類似C#的用法
// // main.swift // test // // Created by CYFang on 6/6/14. // Copyright (c) 2014 CYFang. All rights reserved. // //直接宣告形態 //let temp:String ="C.Y. Fang" //宣告後不可修改 let hello = "Hello, " //宣告後可修改 var name = "C.Y." println(hello + name) name = "Cat" println(hello + name) //陣列 var mArray = ["C.Y.", name] for str in mArray{ println(hello + str) } //字典 var mDictionary = [ 0 : mArray[0], 1: mArray[1]] for var index = 0; index < mDictionary.count; index++ { // println(hello + "\(mDictionary[index])") }
執行結果: