[ 
https://issues.apache.org/jira/browse/GROOVY-11449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17872339#comment-17872339
 ] 

Paul King commented on GROOVY-11449:
------------------------------------

Indeed, if there are no named arguments, Groovy would look for a `foo(Integer 
number)` method to call. You can explicitly create such a method and call the 
Map-based method with an empty Map. Using a default empty Map will generate 
such a method for you.

Did you want to create a PR for this (much appreciated)? Or are you happy for 
me to make a change?

> Improve documentation on Named Method Parameters
> ------------------------------------------------
>
>                 Key: GROOVY-11449
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11449
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Documentation
>            Reporter: Holger Austinat
>            Priority: Minor
>
> Section 3.2.2 of the _Groovy Object Orientation_ documentation describes 
> named method parameters 
> ([http://groovy-lang.org/objectorientation.html#_named_parameters_2]).
> All name parameters are collected in a map, and passed in as first parameter 
> to the called method. One corner case is not mentioned, though: when you call 
> the method without any named parameter, the map is not created and not passed 
> in. Thus, one should make the map optional:
> {code:groovy}
> def foo(Map args=[:], Integer number)
> {code}
> If not optional, one gets a {{{}groovy.lang.MissingMethodException: No 
> signature of method{}}}.
> This is a tricky, unintuitive case which should be explicitly mentioned in 
> the documentation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to