Last active
June 3, 2016 14:45
-
-
Save dogbert17/b3f0aae68415e28903cd6c92d3bc40c2 to your computer and use it in GitHub Desktop.
Attempt to document Mu.does
This file contains hidden or 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 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