Last active
July 1, 2016 15:27
-
-
Save dogbert17/2b669457ea9e4e3203f050222350323d to your computer and use it in GitHub Desktop.
Attempt to document Baggy.ACCEPTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method ACCEPTS | |
Defined as: | |
method ACCEPTS($other) returns Bool:D | |
Used in smart-matching if the right-hand side is a C<Baggy>. | |
If the right hand side is the type object, i.e. C<Baggy>, the method | |
returns C<True> if C<$other> L<does|/routine/does#class_Mu> C<Baggy> | |
otherwise C<False> is returned. | |
If the right hand side is a C<Baggy> object, C<True> is returned only if | |
C<$other> has the same elements, with the same weights, as the invocant. | |
my $breakfast = bag <eggs bacon>; | |
say $breakfast ~~ Baggy; # True | |
say $breakfast.does(Baggy); # True | |
my $second-breakfast = (eggs => 1, bacon => 1).Mix; | |
say $breakfast ~~ $second-breakfast; # True | |
my $third-breakfast = (eggs => 1, bacon => 2).Bag; | |
say $second-breakfast ~~ $third-breakfast; # False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment