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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • None
    • 1.5.7
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: