Got this:
#! /usr/bin/env raku
use v6;
multi blah (@arg) { @arg = 7; }
multi blah ($arg) { $arg = '3'; }
my @array = 1, 2, 3;
blah @array;
say @array;
my $string = 'onetwothree';
blah $string;
say $string;
Get this:
[7]
Cannot assign to a readonly variable or a value
in sub blah at ./chop.raku line 5
in block <unit> at ./chop.raku line 12
I found this behavior surprising, particularly the ability to change to the array outside of the scope of the function.
Can someone please explain why I can change an array argument passed to a function but not a scalar? And is there a way to make arrays read only when passed to a function? Is there any way to make a scalar passed to a function mutable?