Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active June 3, 2016 14:45
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/b3f0aae68415e28903cd6c92d3bc40c2 to your computer and use it in GitHub Desktop.
Save dogbert17/b3f0aae68415e28903cd6c92d3bc40c2 to your computer and use it in GitHub Desktop.
Attempt to document Mu.does
=head2 routine does
method does(Mu $type) returns Bool:D
Returns True if and only if the invocant conforms to type C<$type>.
my $d = Date.new('2016-06-03');
say $d.does(Dateish); # True (Date does role Dateish)
say $d.does(Any); # True (Date is a subclass of Any)
say $d.does(DateTime); # False (Date is not a subclass of DateTime)
A more idiomatic way of doing this would be to use the smart match operator.
my $d = Date.new('2016-06-03');
say $d ~~ Dateish; # True
say $d ~~ Any; # True
say $d ~~ DateTime; # False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment