Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active July 1, 2016 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/2b669457ea9e4e3203f050222350323d to your computer and use it in GitHub Desktop.
Save dogbert17/2b669457ea9e4e3203f050222350323d to your computer and use it in GitHub Desktop.
Attempt to document Baggy.ACCEPTS
=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