📘 Non-value argument passing in Perl 6 subs

📘 Non-value argument passing in Raku subs

N. B. Perl 6 has been renamed to Raku. Click to read more.

By default, you pass the arguments by their values. Despite that, it is not possible to modify them inside the sub. To pass a variable by reference, add the is rw trait. (Note that formally this is not a reference but a mutable argument.)

sub inc($x is rw) {

my $value = 42;
say $value; # 43

Leave a Reply

Your email address will not be published. Required fields are marked *