On 9/26/18 5:55 PM, Curt Tilmes wrote:
For each instance you are using [], it is the same as assigning to a
variable, then calling [] on it.
$ p6 '"a b c d e".words(3).say;'
(a b c)
same as
my @x = "a b c d e".words(3);
@x.say
$ p6 '"a b c d e".words(3)[ 2, 4 ].say;'
(c Nil)
same as
my @x = '"a b c d e".words(3); # same as @x = 'a', 'b', 'c';
@x[2,4].say;
(c, Nil)
The methods don't take []. You are calling [] on the thing that the
methods return.
Yes, I know. And it is human readable too. It is one of the
many reasons I adore Perl 6.
Where in
multi method words(Str:D $input: $limit = Inf --> Positional)
does it state that "words" will do that? Not all methods will.
So it need to be stated when they will.
If
multi method words(Str:D $input: $limit = Inf --> Positional)
is written incorrectly or incompletely, and it is not just me
being dense, how would you rewrite the line?