Either use `rw` or `raw`
Use `rw` if you need it to be mutable.
Use `raw` if you just want to make sure you are getting the actual variable.
That really only applies to `$` parameters though.
---
`@` and `%` parameters are `raw` already.
sub pop-random( @_ ) {
@_.splice( (0..@_.elems).pick, 1 )
}
my @deck = 1..10;
say pop-random @deck; # 7
say @deck; # [1 2 3 4 5 6 8 9 10]
On Sun, Dec 8, 2019 at 1:26 PM Joseph Brenner <[email protected]> wrote:
> What's the sub signature incantation to
> pass-by-reference do you can act directly
> on the structure passed in without juggling
> an alias yourself?
>
> # deal from middle
> my $card = pop_random( @deck );
>