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

Documentation bug: http://groovy.codehaus.org/JN1035-Maps

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • Documentation
    • None

    Description

      At http://groovy.codehaus.org/JN1035-Maps

      we read:

      "We can also use the '' and '<<' operators to add elements to the map. Note that '<<' produces a new map while '' modifies the map:"

      This should be

      "We can also use the '' and '<<' operators to add elements to the map. Note that '=' produces a new map while '<<' modifies the map:"

      as the program in the documentation (which is correct) illustrates:

      def map4a = [:]
      def map5a = map4a
      assert map5a.is(map4a)
      map4a << ['b':'b value'] // the map reference by map4a & map5a is extended
      assert map5a.is(map4a)
      map4a+= ['a':'a value'] // map4a is not the original map4a anymore
      assert !map5a.is(map4a)
      assert map4a == [b:'b value', a:'a value']
      assert map5a == [b:'b value']

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yatima David Tonhofer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: