之前在研究MVC時就有看過這一段教學影片,

這次再看了一次,也進一步把MVC運用在練習的計算機app裡面,

對於optional與struct有更深的認識。

1.一個專案裡面可由多個MVC架構組成


2.String, Double, Array, Dictionary都是struct而非class

3.Classes have inheritance(繼承), struct do not
If you need to subclass or extensible, use classes

4.Classes living in the heap, you have pointer to them. Structs do not live in heap, and they are passed around by copying them.

5.Class -> reference type, struct -> value type

6.Struct會自動初始化裡面的變數

7.在struct裡面要更改變數需要在method前面標記mutating

8.

// func可以宣告成一個變數,並且包含參數與回傳值
var f: (Double) -> Double
f = sqrt
f(81)

9.實用小技巧:Edit All in Scope可以一次更改文件中所有相同的字
除了Cmd + F然後replace之外有另外一種方式可以批次更改內容

Vocabulary:
accumulator 累加器
operand 操作數
operation 運算
mutate 改變
enhance 增強、提高
square root 平方根
discrete 離散的