Last active
October 25, 2015 11:28
-
-
Save KentarouKanno/10bb3fd96cf12e060b2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dict = ["key1":"value1","key2":"value2","key3":"value3"] | |
// 変数を宣言(初期値を設定) | |
var value1: String = "defaultValue" | |
// 値が取得できれば代入 | |
if let tmpValue = dict["key"] { | |
value1 = tmpValue | |
} | |
// 変数を宣言(値が取得できれば代入、できなければ初期値を設定) | |
let value2 = dict["key"] ?? "defaultValue" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment