method freeze
1 | class Pair |
1.1 | (Pair) method freeze |
Documentation for method freeze
assembled from the following types:
class Pair
From Pair
(Pair) method freeze
Defined as:
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»