See Original text in context
method freeze(Pair:)
Makes the value of the Pair
read-only, by removing it from its Scalar container, and returns it.
my = "apple";my = Pair.new('key', );.value = "orange"; # this works as expected.say; # OUTPUT: «key => orange».freeze.say; # OUTPUT: «orange».value = "a new apple"; # FailsCATCH ;# OUTPUT: «X::Assignment::RO: Cannot modify an immutable Str (apple)»
NOTE: this method is deprecated as of 6.d language version. Instead, create a new Pair
, with a decontainerized key/value.
.=Map.=head.say; # OUTPUT: «orange»