develooper Front page | perl.perl6.users | Postings from August 2021

Re: (sigils are awesome, they say ...) Re: pairs of separators froma string

Thread Previous | Thread Next
From:
Fernando Santagata
Date:
August 22, 2021 15:40
Subject:
Re: (sigils are awesome, they say ...) Re: pairs of separators froma string
Message ID:
CAJ+jyGhMLqsoDtf3XKh6BatOtFhAJ2bB9CA_LaJEokidy68reg@mail.gmail.com
On Sun, Aug 22, 2021 at 2:58 PM Marc Chantreux <eiro@phear.org> wrote:

> so of course i tried
>
> my (@a, @b) = { .[0,2…∞], .[1,3…∞] }.(q<AABBCCDD>.comb);
>
> because i have two lists and two containers. this doesn't work.
> which means @ and $ combines with = to define how things are stored
> but i don't understand how for the moment.
>

Try:

> my (@a, @b) := { .[0,2…∞], .[1,3…∞] }.(q<AABBCCDD>.comb);say @a;say @b
(A B C D)
(A B C D)

In this case the binding operator ':=' makes the difference.

When one uses the assignment operator '=', the right side value is
interpreted as an array of two elements, each one is a list of four
elements: [(A B C D) (A B C D)]. When one binds, each array is bound to one
list.

-- 
Fernando Santagata

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About