Created
May 26, 2016 19:31
-
-
Save dogbert17/206507725af16451cd100033d5df0f91 to your computer and use it in GitHub Desktop.
Feeble attempt to document method 'default' in class Hash
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 method default | |
Defined as: | |
method default returns ??? # what should be written here | |
Usage: | |
Hash.default | |
Returns the default value of the invocant, i.e. the value which is returned | |
when a non existing key is used to access an element in the C<Hash>. | |
Unless the C<Hash> is declared as having a default value by using the | |
L<is default|/routine/is default> trait the method returns the type object C<(Any)>. | |
my %h1 = 'apples' => 3, 'oranges' => 7; | |
say %h1.default; # (Any) | |
say %h1{'bananas'}; # (Any) | |
my %h2 is default(1) = 'apples' => 3, 'oranges' => 7; | |
say %h2.default; # 1 | |
say %h2{'apples'} + %h2{'bananas'}; # 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment