On Wed, Sep 26, 2018 at 8:58 AM Todd Chester <toddandma...@zoho.com> wrote:
> Hi All, > > Over on > https://docs.perl6.org/routine/words > I see > > multi method words(Str:D $input: $limit = Inf --> Positional) > > HOW IN THE WORLD did they convert `$limit = Inf` into an > array index!?!?! > It's not. It's a limit: eirik@greencat[19:41:18]~$ perl6 -e '.say for "foo bar baz qux".words(2)' foo bar eirik@greencat[19:41:29]~$ I see from your other email that you're using square brackets. That's what makes a zero-based index: eirik@greencat[19:41:29]~$ perl6 -e '.say for "foo bar baz qux".words[2]' baz eirik@greencat[19:43:00]~$ But this index is not an argument to the words method. It is an argument to the .[ ] postcircumfix. That these are different things is perhaps more easily seen when they're both present: eirik@greencat[19:45:54]~$ perl6 -e '.say for "foo bar baz qux".words(3)[*-1]' baz eirik@greencat[19:45:59]~$ Here, it may be clearer that the $limit is 3, and the index is *-1. Eirik