「Swift」strideで配列の要素を取得する方法
構文
for i in stride(from: 開始値, to: 終了位置, by: 間隔)
サンプルコード
let cftArr = ["A001", "B002", "C003", "D004","E005"] for i in stride(from: 0, to: cftArr.count, by: 1) { print("\(cftArr[i])") }
実行結果
A001
B002
C003
D004
E005
Coding Changes the World
構文
for i in stride(from: 開始値, to: 終了位置, by: 間隔)
サンプルコード
let cftArr = ["A001", "B002", "C003", "D004","E005"] for i in stride(from: 0, to: cftArr.count, by: 1) { print("\(cftArr[i])") }
実行結果
A001
B002
C003
D004
E005