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

map.entrySet().each { it.value = "foo" } should either update map or explode

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Problem
    • Affects Version/s: None
    • Fix Version/s: 1.5.7
    • Component/s: None
    • Labels:
      None

      Description

      def x = [a:1, b:2, c:3]
      x.entrySet.each

      { it.value = it.value * it.value }

      println x

      1. Prints [a:1, b:2, c:3] – would expect it to print [a:1, b:4, c:9], or to explode.
      2. Instead of either updating or exploding, it silently fails.
      3. Note: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html#entrySet() – the entrySet is explicitly backed by the map,
      4. and by requirement of the Java API, changes to the entrySet must be reflected in the underlying map.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              robertfischer Robert Fischer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: