參考網站
- http://tommy60703.gitbooks.io/swift-language-traditional-chinese/
var str = "Hello, playground"
println("這是測試")
println(str)
/*
* 練習變數與常數
*/
var myVariable = 70
let myVariable2 = 70.0
myVariable = 80 //變數可以再次賦予數值,myVariable2 = 80會出錯
/*
* 練習型別轉換
*/
let aaa :Float = 4
let label = "The width is"
let width = 94
let widthlabel = label + String(width)
let apples = 3
let oranges = 5
let appleSummary = "I have \(apples) apples."
let fruitSummary = "I have \(apples + oranges) apples."
/*
* 練習陣列
*/
var shoppingList = ["catfish" , "water" , "tulips" , "blue paint"]
shoppingList[1] = "bottle of water"
shoppingList .append("test")
println(shoppingList)
var occupations = ["Name":"Tod","Tel": "12345"]
println(occupations)
occupations["address"] = "Taipei"
println(occupations)
沒有留言:
張貼留言