Re: This seems to be wrong
[email protected] (Brandon Allbery) Sun, 18 Sep 2016 18:40:33 -0400
| Newsgroups | perl.perl6.language |
|---|---|
| Message-ID | <CAKFCL4VbmftNqC21seOAAYKu3nJqTU=OT2Wgr1MyifezvOJyUw@mail.gmail.com> |
On Sun, Sep 18, 2016 at 6:36 PM, Trey Harris <[email protected]> wrote: > Does not being defined on Any explain why the error for @input.map( .Str ) > is different (Use of uninitialized value $_ of type Any in string context) > than the error for @input.map( .Num ) (Method 'Num' not found for > invocant of class 'Any'), but both*.Str and *.Num work in the .map? > Yes. Without the *, it's doing $_.Str or $_.Num when $_ is the one *outside* the map call, which has no current value (and so is (Any)); in the Str case it is invoking Any.Str and failing on the undefined value, in the Num case it can't find the method for Any. With the *, it's a closure and applies to the $_ current for each iteration of map; the invocant is a defined Str. -- brandon s allbery kf8nh sine nomine associates [email protected] [email protected] unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net