Last active
May 29, 2016 15:05
-
-
Save dogbert17/aee462bdb51ef1d71caf3915e449c3b3 to your computer and use it in GitHub Desktop.
Attempt to document method default in class Array
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 | |
Usage: | |
Array.default | |
Returns the default value of the invocant, i.e. the value which is returned | |
when trying to access an element in the C<Array> which has not been | |
previously initialized or when accessing an element which has explicitly | |
been set to C<Nil>. Unless the C<Array> 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 @a1 = 1, "two", 2.718; | |
say @a1.default; # (Any) | |
say @a1[4]; # (Any) | |
my @a2 is default(17) = 1, "two", 3; | |
say @a2.default; # 17 | |
say @a2[4]; # 17 | |
@a2[1] = Nil; # (resets element to its default) | |
say @a2[1]; # 17 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment