Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-11449

Improve documentation on Named Method Parameters

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Documentation
    • None

    Description

      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:

      def foo(Map args=[:], Integer number)
      

      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.

      Attachments

        Activity

          People

            paulk Paul King
            haustinat Holger Austinat
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: