Can you explain what those examples are supposed to demonstrate?
What I got out of it is that the naive rule is:
1) the match operator compares references.
Therefore, if you smart match @arr ~~ 2, you are doing this:
my @arr = (10, 20, 30); my $aref = \@arr; say $aref; #ARRAY(0x1810e90) 0x1810e90 ~~ 2 --output:-- NOPE!
However, the naive rule breaks down here:
my @a = (10, 20, 30); my @b = (10, 20, 30); my $aref = \@a; my $bref = \@b; say $aref; say $bref; --output:-- ARRAY(0x1810e90) ARRAY(0x181ace0) #yet... say @a ~~ @b ? 'yes' : 'no'; --output:-- yes
So you can't really say that the smart operator is comparing references, otherwise @a and @b would not match.
In reply to Re^2: smart match operator should be smarter!
by 7stud
in thread smart match operator should be smarter!
by 7stud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |