create. Creating an empty hash or copying existing hash
^hash::create[]
^hash::create[existing hash or hashfile oruser-defined objectorfile]
If existing hash or hash compatible object is not specified, an empty hash will be created. Otherwise, the constructor will make a copy of it.
An empty hash is needed when we are going to dynamically fill it with data, e.g.:
$dyn[^hash::create[]]
^for[i](1;10){
$dyn.$i[$value]
}
Before performing loop for, we have defined what exactly we are going to fill with data.
If we are planning to change a hash's content intensively, but still want to preserve initial values, we had better create a copy of the hash. In this case, only the hash's copy will be changed, while initial values will remain intact. For example:
$pets[
$.pet[Dog]
$.food[Bone]
$.good[Collar]
]
$pets_copy[^hash::create[$pets]]
Note: field _default is also copied. [3.1.4]