pkg_.merge(P1;P2)
When applied to a package, returns a new package that is the union of
P1
and P2
, with the values of P2
taking precedence.
Description
pkg_.merge
is a recursive version of pkg_.update
.
pkg_.merge
is a user-defined function (defined with
<def_ufun/>
). If you are not running your query in GUI2,
pkg_.merge
will only work if you import the
pkg_
library: <import
path="default.library.types.pkg_"/>
Syntax
pkg_.merge(P1;P2)
Input
Argument | Type | Description |
---|---|---|
P1 |
any | The name of a package variable |
P2 |
any | The name of a second package variable |
Return Value
pkg_.merge
returns a package that is the union of P1
and
P2
.Examples
<set pkga="{pkg('k1' 'k2' 'k3';'v1' 'v2' pkg('ck1' 'ckN';'cv1' 'cvN'))}"/> <set pkgb="{pkg('k1' 'new_key';'new_val_1' 'new_val')}"/> <set merged="{pkg_.merge(@pkga;pkgb)}"/>
Merged result: {pkg('k1' 'k2' 'k3' 'new_key';'new_val_1' 'v2' pkg('ck1'
'ckN';'cv1' 'cvN') 'new_val')}
<set pkga="{pkg('k1' 'k2' 'k3';'v1' 'v2' pkg('ck1' 'ckN';'cv1' 'cvN'))}"/>
<set pkgb="{pkg('k3';pkg('ck1';'new child value'))}"/>
<set merged="{pkg_.merge(@pkga;pkgb)}"/>
Merged result: {pkg('k1' 'k2' 'k3';'v1' 'v2' pkg('ck1' 'ckN';'new
child value' 'cvN'))}