Hi Paul, Thanks for sharing this.
I agree with you on making it clearer by restating it perhaps by adding link you mentioned after the code snippet in documentation. I can raise a PR if you think it's a good idea. Thanks and Regards Niranjan On Wed, 30 Mar 2022, 5:32 pm Paul King, <pa...@asert.com.au> wrote: > Perhaps the documentation around methods/constructors[1] is clearest: > "Parameters are dropped from the right, however mandatory parameters > are never dropped." > > So the following is fine (showing it's not just the last parameter): > > def clos = { a, b = 2, c = 100 -> a * b + c } > assert clos(5, 4, 1) == 21 > assert clos(5, 4) == 120 > assert clos(5) == 110 > > The Closure documentation[2] indicates that it follows the same > principle as methods but perhaps > could be restated to make it clearer. > > Cheers, Paul. > > =========== > > [1] Method doco: > https://docs.groovy-lang.org/latest/html/documentation/#_default_arguments > [2] Closure doco: > https://docs.groovy-lang.org/latest/html/documentation/#_normal_parameters > > > On Wed, Mar 30, 2022 at 1:36 PM Niranjan Ghule <niranjan.gh...@gmail.com> > wrote: > > > > Hi Team, > > > > In Closure with default values in parameters, only the last parameter > can have a default value, isn't it? > > > > We can add this detail in documentation. >