「Swift」 for in strideのサンプル

2021年7月9日

書式
for 変数名 in stride(form:最小値,to:最大値,by:値)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
let cInter = 5
for cft in stride(from: 0, to: 20, by: cInter){
print(cft)
}
print("**************")
for cft in stride(from: 0, through: 20, by: cInter){
print(cft)
let cInter = 5 for cft in stride(from: 0, to: 20, by: cInter){ print(cft) } print("**************") for cft in stride(from: 0, through: 20, by: cInter){ print(cft)
let cInter = 5
for cft in stride(from: 0, to: 20, by: cInter){
    print(cft)
}
 
print("**************")
for cft in stride(from: 0, through: 20, by: cInter){
    print(cft)

実行結果
0
5
10
15
20
**************
0
5
10
15
20

Swift

Posted by arkgame