You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expected:
"def acceptsClosure(Closure a, Closure b) {}
acceptsClosure { println(it) } {
println(it)
}"
but was:
"def acceptsClosure(Closure a, Closure b) {}
acceptsClosure { println(it) } ,
{println(it)
}"
Note
The groovy language is rather picky with omitting parentheses. For closures no comma is allowed, except when you join them with other types. So you need to define it like this, or it won't compile:
defacceptsClosure(Closurea, Closureb) {}
acceptsClosure { println(it) } { println(it) }
deffunctionX(Stringa, Stringb, Stringc, Stringd) {}
functionX "a", "b", "c", "d"defcombination(Stringa, Closureb, Closurec, Stringd) {}
combination "a", { println(it) }, { println(it) }, "d"defcombination2(Closurea, Stringd) {}
combination2({ println(it) }, "d") // starting with a closure seems not be possible without parentheses!
The text was updated successfully, but these errors were encountered:
Problem
Groovy let you omit the parentheses for function arguments. This does not work if you use multiple closures.
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
A test that succeeds.
What did you see instead?
Note
The groovy language is rather picky with omitting parentheses. For closures no comma is allowed, except when you join them with other types. So you need to define it like this, or it won't compile:
The text was updated successfully, but these errors were encountered: