Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active May 11, 2016 21:16
Show Gist options
  • Save dogbert17/81529690ccf4ded4f00be96faf999b0c to your computer and use it in GitHub Desktop.
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
=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