Logo

Programming-Idioms

History of Idiom 2 > diff from v126 to v127

Edit summary for version 127 by andyjduncan:
New Groovy implementation by user [andyjduncan]

Version 126

2020-10-06, 20:26:08

Version 127

2020-10-10, 11:45:25

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
10.times {
    println 'Hello'
}​
Doc URL
https://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/Number.html#times(groovy.lang.Closure)
Demo URL
https://groovyconsole.appspot.com/script/5138696969912320