Logo

Programming-Idioms

History of Idiom 2 > diff from v85 to v86

Edit summary for version 86 by mjh:
[Kotlin] Unnecessary declaration of i

Version 85

2019-09-26, 21:43:09

Version 86

2019-09-26, 21:49:27

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Code
for( i in 0..9 ){
    println("Hello")
}
Code
(0..9).forEach {
    println("Hello")
}
Comments bubble
0..9 is inclusive
Comments bubble
0..9 is inclusive
Doc URL
https://www.programiz.com/kotlin-programming/for-loop
Doc URL
https://www.programiz.com/kotlin-programming/for-loop