Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
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
- duplicates
-
GROOVY-6472 Documentation related to adding entries to maps appears incorrect in wiki
- Closed