Skip to content

Commit af03f46

Browse files
authored
Add note about modifying maps with the + operator [ci skip] (#3740)
Signed-off-by: Ben Sherman <[email protected]>
1 parent 6aecc4e commit af03f46

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/script.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ To add data to or modify a map, the syntax is similar to adding values to list::
9999
scores["Pete"] = 3
100100
scores["Cedric"] = 120
101101

102+
You can also use the ``+`` operator to add two maps together::
103+
104+
new_scores = scores + ["Pete": 3, "Cedric": 120]
105+
106+
When adding two maps, the first map is copied and then appended with the keys from the second map. Any conflicting keys
107+
are overwritten by the second map.
108+
109+
.. tip::
110+
Appending an "update" map is a safer way to modify maps in Nextflow, specifically when passing maps through channels.
111+
This way, any references to the original map elsewhere in the pipeline won't be modified.
112+
102113
Learn more about maps:
103114

104115
* `Groovy Maps tutorial <http://groovy-lang.org/groovy-dev-kit.html#Collections-Maps>`_

0 commit comments

Comments
 (0)