Front page | perl.perl6.users |
Postings from January 2021
list assignment
Thread Next
From:
Brian Duggan
Date:
January 19, 2021 18:18
Subject:
list assignment
Message ID:
YAcicJixZZcyOzQb@bduggan-C02DX7U3MD6R
Hi Folks,
I ran into this situation today, which seems counterintuitive:
my @one = 1,2,3;
my @two = 4,5,6;
my @both = @one,@two;
my @first = @both[0];
say @one.raku;
say @first.raku;
output:
[1, 2, 3]
[[1, 2, 3],]
I was expecting @first and @one to be the same.
I discovered that I could instead write either of these --
my (@first) = @both[0];
my @first := @both[0];
or I could change the @both assignment to be
my @both := @one, @two;
..but I wonder if there's an idiomatic approach -- or
way of thinking about this -- that makes this flow more
intuitive.
thanks
Brian
Thread Next
-
list assignment
by Brian Duggan