You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Holger Austinat (Jira)" <ji...@apache.org> on 2024/08/09 06:09:00 UTC

[jira] [Created] (GROOVY-11449) Improve documentation on Named Method Parameters

Holger Austinat created GROOVY-11449:
----------------------------------------

             Summary: 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


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)