Last active
May 11, 2016 21:16
-
-
Save dogbert17/81529690ccf4ded4f00be96faf999b0c to your computer and use it in GitHub Desktop.
Attempt to write some docs for Pair.freeze - perhaps more text is needed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method freeze | |
Defined as: | |
method freeze(Pair:D:) | |
Usage: | |
PAIR.freeze | |
Makes the value of the C<Pair> read-only, by removing it from its Scalar container, and returns it. | |
my $str = "apple"; | |
my $p = Pair.new('key', $str); | |
$p.value = "orange"; # this works as expected | |
$p.say; # key => orange | |
$p.freeze.say; # orange | |
$p.value = "a new apple"; # Fails with 'Cannot modify an immutable Str' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment