1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-06 14:56:54 +02:00

Merge pull request #3559 from b-xor-a/master

[perl6/en] Fixed output
This commit is contained in:
Divay Prakash
2019-08-03 00:36:55 +05:30
committed by GitHub

View File

@@ -247,11 +247,12 @@ concat3(|@array); #=> a, b, c
## arguments. If you really need to, you can ask for a mutable container by ## arguments. If you really need to, you can ask for a mutable container by
## using the `is rw` trait: ## using the `is rw` trait:
sub mutate( $n is rw ) { sub mutate( $n is rw ) {
$n++; $n++; # postfix ++ operator increments its argument but returns its old value
} }
my $m = 42; my $m = 42;
mutate $m; #=> 43 mutate $m; # the value is incremented but the old value is returned
#=> 42
say $m; #=> 43 say $m; #=> 43
## This works because we are passing the container $m to the `mutate` sub. ## This works because we are passing the container $m to the `mutate` sub.