3 ms·
Indeed. That was because smart-matching in Perl was symmetric. The smart-matching in Raku (formerly known as Perl 6) is asymmetric and customizable. If you w
by lizmat 6y ago
Indeed. That was because smart-matching in Perl was symmetric.
The smart-matching in Raku (formerly known as Perl 6) is asymmetric and customizable. If you write:
a ~~ b
you are effectively executing:
b.ACCEPTS(a)
In other words, the right hand side of the smart-match is responsible for accepting the left hand side. So as a developer of a class, you can add your own ACCEPTS (multi-)method to govern how your class will handle smart-matching.