I have to admit, I find this surprising. Looking at the perldocs for perlop, I see that:
Ok, that's fine. So now I need to check how Any ~~ $_ works. So, a little further down, I see:Left Right Description and pseudocode ============================================================== += [...] Any ARRAY smartmatch each ARRAY element[3] like: grep { Any ~~ $_ } ARRAY
Now, this is interesting. When we see a number on the right, we compare with ==, even if the left doesn't look like a number. That seems wrong. I would have expected:Left Right Description and pseudocode ============================================================== += [...] Any Num numeric equality like: Any == Num Num nummy[4] numeric equality like: Num == nummy undef Any check whether undefined like: !defined(Any) Any Any string equality like: Any eq Any
Maybe a bug report should be opened :-) (Though as I understand it, there's a fair bit of consternation about the whole smart-match thing in the first place.) I would also expect that nummy would include objects with == overridden.nummy[4] Num numeric equality like: nummy == Num
In reply to Re: given-when construct unexpected bahavior wit arrays
by Tanktalus
in thread given-when construct unexpected behavior with arrays
by mantager
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |