Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active May 29, 2016 15:05
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/aee462bdb51ef1d71caf3915e449c3b3 to your computer and use it in GitHub Desktop.
Save dogbert17/aee462bdb51ef1d71caf3915e449c3b3 to your computer and use it in GitHub Desktop.
Attempt to document method default in class Array
=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