CS日誌03 - Swift Coding

CS日誌03 - Swift Coding

L4 建立War Card Game

  • 自己嘗試做一遍
  • padding可以上下左右各別調整

L5 學習基本Swift Coding

  • 建立Xcode playground

var greeting: String = "Hello, playground"

  • var: declare (create) a variable(變數)
  • greeting: variable name
  • : String: data type of the variable,可省略,會自動辨別第一次輸入的是哪一種資料
  • =: assign data
  • Hello, playground: text data,加新的greeting="...(同種類data)"就會取代原本的

Data種類

  1. String:Text data 字串
  2. Int, Double:Numerical data (Integers整數 & decimals小數)
  3. Bool:Boolean data (True, False, ...)

let greeting: String = "Hello, playground"

  • let: declare a constant(常數),沒辦法改,optimization > var
  • greeting:  constant name
  • : String: data type of the constant

20250314