Hash operations

Concatenation

You can concatenate hashes in the same way as strings, with +. If both hashes contain the same key, the hash on the right-hand side of the + takes precedence. Example:

<#assign ages = {"Joe":23, "Fred":25} + {"Joe":30, "Julia":18}>
- Joe is ${ages.Joe}
- Fred is ${ages.Fred}
- Julia is ${ages.Julia}  

produces this output:

- Joe is 30
- Fred is 25
- Julia is 18  

NOTE: Do not use hash concatenation for many repeated concatenations, such as adding items to a hash inside a loop. It's the same as with the sequence concatenation.

Next steps

String operations

Hash operations