Re: Passing arrays to subroutines

2015-03-19 Thread Tom Browder
On Thu, Mar 19, 2015 at 10:15 AM, Moritz Lenz wrote: > On 03/19/2015 04:05 PM, Tom Browder wrote: >> >> In Perl 5 I can do this: ... >> 1. How can I combine arrays @a and @b into one array? > > > generally with the comma operator: > > my @combined = @a, @b; It looks like I can also do this: my

Re: Passing arrays to subroutines

2015-03-19 Thread Moritz Lenz
On 03/19/2015 04:05 PM, Tom Browder wrote: In Perl 5 I can do this: my @a = (1, 2); my @b = (3); foo(@a,@b); sub foo { my $n = @_; die "Wrong num args: $n" if ($n != 3);} In Perl 6 I think this is correct (or nearly so): sub foo(*@args) { die "Wrong num args: { @args.elems }" if @args.ele

Passing arrays to subroutines

2015-03-19 Thread Tom Browder
In Perl 5 I can do this: my @a = (1, 2); my @b = (3); foo(@a,@b); sub foo { my $n = @_; die "Wrong num args: $n" if ($n != 3);} In Perl 6 I think this is correct (or nearly so): sub foo(*@args) { die "Wrong num args: { @args.elems }" if @args.elems != 3;} Questions for Perl 6: foo is now de