I suspect this is intentional but was before my time. Try this also: int triggered = 0 def o1 = { -> triggered++ } def o2 = { println '*' + it; triggered++ }
println(o1) // ConsoleScript11$_run_closure1@xxxxxxxx println(o2) // ConsoleScript11$_run_closure2@yyyyyyyy assert triggered == 0 println("xyzzy$o1") // xyzzy0 assert triggered == 1 println("XX${o2}YY${o2(42)}ZZ") // *42\n*XX\nXXYY1ZZ assert triggered == 3 On Fri, Dec 22, 2017 at 8:20 AM, Nathan Harvey <nathanwhar...@gmail.com> wrote: > Take the following code: > > int triggered = 0 > def o = { -> triggered++ } > > println(o) // A > println("$o") // B > println("${o}") // C > > After A, triggered is 0; after B, it's 1; after C, it's 2. The Closure is > being called and the result of it is being printed instead. Is this > behavior > intended? > > > > -- > Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html >