Swiftで遊ぼう! - 228 - Developing iOS 8 Apps with Swift - Dictionary
Swiftで遊ぼう!の古い記事-> Life-LOG OtherSide
ポール先生の講義はArrayからDictionaryの解説に入って知らないことが出てきた。
var testDictionary = [String: Int]() testDictionary = ["test1":1, "test2":2]
空のDictionaryを作ってから「Key:value」のセットを代入する方法は基本であり解説はいらないだろう。
key値によるサブスクリプトでvalue値を呼び出す場合オプショナル値になるというのを知らなかった。
上記testDictionaryに次のように存在しないvalueで呼び出すとオプショナル値になる。
var number3 = testDictionary["test3"]
number3は「Int?」だ。
今日はこここまで。