in reply to Re^4: smart match operator should be smarter!
in thread smart match operator should be smarter!

Yup! Have tried this in 5.10.1 and now see the difference.

use strict; use warnings; use 5.010; my @arr = (2, 5 , "aaa"); say "\@arr ~~ 5 matches" if @arr ~~ 5; say "5 ~~ \@arr matches" if 5 ~~ @arr; say "\@arr ~~ 3 matches" if @arr ~~ 3; __END__ 5 ~~ @arr matches

But after reading "Smart matching in detail" from perlsyn I have the impression that @arr ~~ 3 expression falls under

Any Num numeric equality $a == $b
rule, so it should be equal to @arr == 3, and it's not, so what rule is actually applied in this case? And BTW is there any way to see what comparison have been actually performed?

Replies are listed 'Best First'.
Re^6: smart match operator should be smarter!
by ikegami (Patriarch) on Nov 22, 2009 at 18:09 UTC