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.

Reply via email to