Answering my own question, the operator sets the type of $. That's what
gradual typing is all about!

$ seq 5 | raku -ne "say $++"

0

1

2

3

4

$ seq 5 | raku -ne "say $ ~= 'Hi' "

Hi

HiHi

HiHiHi

HiHiHiHi

HiHiHiHiHi

$ seq 5 | raku -ne "say $++, $ ~= ' Hi' "

0 Hi

1 Hi Hi

2 Hi Hi Hi

3 Hi Hi Hi Hi

4 Hi Hi Hi Hi Hi

-y


On Mon, Aug 31, 2020 at 4:39 PM Aureliano Guedes <guedes.aureli...@gmail.com>
wrote:

> Basically :
>
> $ raku -e 'my $a = 1; say ++$a; say $a'
> 2
> 2
> $ raku -e 'my $a = 1; say $a++; say $a'
> 1
> 2
>
> On Mon, Aug 31, 2020 at 8:36 PM yary <not....@gmail.com> wrote:
>
>> $ by itself is an anonymous variable, putting ++ after starts it at 0
>> (hmm or nil?) and increments up.
>>
>> By putting the plus plus first, ++$, it will start at 1, thanks to
>> pre-increment versus post increment
>>
>> On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users <
>> perl6-us...@perl.org> wrote:
>>
>>> On 2020-08-31 05:53, Brian Duggan wrote:
>>> > On Monday, August 24, Curt Tilmes wrote:
>>> >> $ cat Lines.txt | raku -e '.say for lines()[3,2,5]'
>>> >
>>> > The -n flag is an option here too:
>>> >
>>> >     raku -ne '.say if $++ == 3|2|5' Lines.txt
>>> >
>>> > Brian
>>> >
>>>
>>> Hi Bill,
>>>
>>> Works beatifically! And no bash pipe!
>>>
>>> $ raku -ne '.say if $++ == 3|2|5' Lines.txt
>>> Line 2
>>> Line 3
>>> Line 5
>>>
>>> What is `$++`?
>>>
>>> -T
>>>
>>
>
> --
> Aureliano Guedes
> skype: aureliano.guedes
> contato:  (11) 94292-6110
> whatsapp +5511942926110
>

Reply via email to