Skip to the content
Documentation

Hash merging

No ratings yet

This function also works for hashes.

def $a = hash('a', 'b')
def $b = hash('c', 'd')
def $c = $a|merge($b)

will make

$c['a'] = 'b'
$c['c'] = 'd'

Very useful for growing hashes iteratively. However, bear in bind that hashes cannot have numbers as keys! I lost an hour trying to figure out why my

foreach

didn't work. :-)