Copy a string: Difference between revisions
m
→{{header|Perl 6}}: update to ease automated testing
No edit summary |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: update to ease automated testing) |
||
Line 1,455:
<!-- SqrtNegInf 2016-01-16 This is NYI, so until such time as it is, leaving this section commented
You can also create a read-only binding which will allow read access to the string but prevent modification except through the original variable.
<lang perl6>
#my $bound-ro ::= $original;
#say $bound-ro; # prints "Hello."
#try {
# $bound-ro = 'Runtime error!';
# CATCH {
# say "$!"; # prints "Cannot modify readonly value"
# };
#};
say $bound-ro; # prints "Hello."
$original = 'Goodbye.';
|