「Ios/swift/制御とループ」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→for_inループ) |
|||
行22: | 行22: | ||
var user = ["name": "taro", "birth": "2000-10-10"] | var user = ["name": "taro", "birth": "2000-10-10"] | ||
for (key, val) in user { | for (key, val) in user { | ||
− | print( "key = \(key), val = \(val)" ) | + | print("key = \(key), val = \(val)") |
} | } |
2016年6月25日 (土) 05:15時点における版
if制御
if str == "hello" { } else { }
switch制御
switch str { case "hello": break; case "good": break; default: break; }
for_inループ
var names:[String] = ["taro", "jiro", "saburo"] for name in names { print(name) } // ディクショナリのループ var user = ["name": "taro", "birth": "2000-10-10"] for (key, val) in user { print("key = \(key), val = \(val)") }