According to Programming Perl, using smartmatch with "any" on the left and a number on the right checks numeric equality:
------------------------------------------------------------------------------
| Left | Right | Description | Like (But Evaluated in Boolean Context) |
------------------------------------------------------------------------------
| Any | Num | Numeric equality | Any == Num |
Therefore, I expect the following to output 1
:
my @arr = ('aaa');
my $num = 1;
say @arr ~~ $num;
but it actually outputs the empty string.
I thought @arr
would be converted to scalar 1
because it has 1 element, so say @arr ~~ $num
would be equivalent to say @arr == $num
.
Why is @arr ~~ $num
different from @arr == $num
?