Kotlin for

텅텅텅·2023년 5월 28일
0

Kotlin

목록 보기
5/6

"for" structure in Kotlin

for(a in n1 .. n2){
}

basic "for" statement

for(a in 1..5){
	println("a = $a")
}

"for" statement increasing value by 2. Use "step + n"

for(a in 1..5 step 2){
	println(a)
}

decreasing-value "for" statement uses caption, "downTo"

for(a in 10 downTo 1){
	println(a)
}
for(a in 10 downTo 1 step 2){
	println(a)
}
profile
아무것도모르오

0개의 댓글