On Thu, Sep 21, 2017 at 2:37 AM, Luca Ferrari wrote:
> Out of cursiosity: what is the diffence between using "is copy" and "<->"?
> Seems to me the map example can work with both.
>
<-> is the same as "is rw" and requires that the thing being bound be a
mutable container, which will be altered i
You can also use a whatever star with the subst method to avoid the block
entirely, and just chain method calls:
my @fields = $line.split( ',' ).map: *.subst(/\'/, "", :g).subst(/^\"|\"$/,
"", :g);
On Wed, Sep 20, 2017 at 11:37 PM, Luca Ferrari
wrote:
> On Tue, Sep 19, 2017 at 2:43 PM, Timo Pa
On Tue, Sep 19, 2017 at 2:43 PM, Timo Paulssen wrote:
> perl6 -e '.perl.say for "hello, how, are, you".split(",").map: -> $_
> is copy { s:g/a//; s:g/^ \s|\s $/O/; $_ }'
> "hello"
> "Ohow"
> "Ore"
> "Oyou"
Thanks.
Out of cursiosity: what is the diffence between using "is copy"
You'll have to type the $_ of the block as "is copy" if you want to do
this. Another way would be to have "is rw" but that can of course only
work if a container is present in what you map over; there isn't in this
case.
perl6 -e '.perl.say for "hello, how, are, you".split(",").map: -> $_
is c
Hi all,
I'm trying to understand how to use map correctly to apply several
regexps at once, something like:
my @fields = $line.split( ',' ).map: { s:g/\'//; s:g/^\"|\"$//; $_ };
while the first regexp works, the second fails with "Cannot modify an
immutable Str", but the topic variable should b