in reply to smart match operator should be smarter!

Ok, thanks. I see that my last problem is the same problem: you can't use the match operator with a literal. So you have to do this:

my @arr1 = (2, 34); my $val = 34; say "34" if $val ~~ @arr1; #34

But the smart match operator is supposed to be commutative, yet:

my @arr1 = (2, 34); my $val = 34; say "34" if @arr1 ~~ $val; #no output...??

Replies are listed 'Best First'.
Re^2: smart match operator should be smarter!
by ikegami (Patriarch) on Nov 21, 2009 at 19:04 UTC

      Fixing the aforementioned bugs required making ~~ non-commutative.

      I don't see any aforementioned bugs???

      Ok, so not commutative anymore. Another flea from the llama 5th bit me.

        It made overloading ~~ impossibly complex. I think there were other problems too. If you use given/when, you shouldn't notice a difference.