union. Joining hashes

^hash_a.union[hash_b]

The method joins two hashes. It returns hash containing all keys from
$hash_a and those keys from $hash_b, which are absent in $hash_a. The result has to be assigned to a new hash.

Example

Code…

$man[
   $.name[
Jack]
   $.age[
22]
   $.sex[
m]
]
$woman[
   $.name[
Mary]
   $.age[
20]
   $.weight[
50]
]
$union_hash[^man.union[$woman]]

…will result in hash
$union_hash:

$union_hash[
   $.name[Jack]
   $.age[22]
   $.sex[m]
   $.weight[50]
]



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 30.03.2004