groovy
  1. groovy
  2. GROOVY-4731

sample code in javadoc of Map#spreadMap() don't works

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8-rc-4
    • Component/s: groovy-jdk
    • Labels:
      None
    • Number of attachments :
      0

      Description

      At the GDK document of Map#toSpreadMap(),

      http://groovy.codehaus.org/groovy-jdk/java/util/Map.html#toSpreadMap()

      says:

      For examples, if there is defined a function like as

      def fn(a, b, c, d)

      Unknown macro: { return a + b + c + d }

      , then all of the following three have the same meaning.
      println fn(a:1, [b:2, c:3].toSpreadMap(), d:4)
      println fn(a:1, *:[b:2, c:3], d:4)
      println fn(a:1, b:2, c:3, d:4)

      I think there are at least 2 problems here.

      1) fn should take Map parameter like:

      def fn(Map m) { return m.a + m.b + m.c + m.d }

      2) I changed it in 1) way but I get following error at the line calling toSpreadMap().

      Caught: groovy.lang.MissingMethodException: No signature of method: d.fn() is applicable for argument types: (java.util.LinkedHashMap, groovy.lang.SpreadMap) values: [[a:1, d:4], [:]]
      Possible solutions: fn(java.util.Map), run(), run(), any(), run(java.io.File, [Ljava.lang.String, any(groovy.lang.Closure)
      at d.run(d.groovy:3)

        Activity

        Paul King made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Paul King [ paulk ]
        Fix Version/s 1.8-rc-4 [ 17245 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Paul King
            Reporter:
            UEHARA Junji
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: