A closure as the second argument is the only case where arguments don't need to be comma separated. These both work:
test true, "oops" test (true), "oops" Cheers, Paul. On Thu, Aug 15, 2024 at 9:47 PM OCsite <o...@ocs.cz> wrote: > > Hi there, > > is this my fault, for I missed some documentation somewhere, or a parser > fault, for it should have recognised the bool as the 1st and string as the > 2nd argument and just call “test” with “true, 'oops'” in the last case (as > I've, perhaps mistakenly, assumed)? > > === > > 782 ocs /tmp> <q.groovy > > def test={ boolean always=false, val -> > > println "$always: $val" > > } > > test "hi" > > test(true, "ha") > > test(true) { -> "ho" } // a closure is properly recognised as 2nd arg > > test(true) "oops" // a string is not?!? > > 782 ocs /tmp> /usr/local/groovy-4.0.0-alpha-1/bin/groovy q > > false: hi > > true: ha > > true: ho > > false: true > > Caught: java.lang.NullPointerException: Cannot get property 'oops' on null > object > > 783 ocs /tmp> > > === > > Thanks and all the best, > OC