The following Groovy code prints a range of numbers from 1 to 5.
(1..5).each {println it} However, when I forget to add the parenthesis, and do this:
1..5.each { println it} It prints only 5
Why is this legal Groovy syntax? I would expect this to either behave as the (1..5) version or to throw an exception saying that I have forgotten the parenthesis.
.eachprobably binds stronger than.., so your second command is equivalent to1..(5.each { println it})where the range is unused.