Skip to content

Commit

Permalink
native traits: document contextual behavior of elements
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Feb 10, 2018
1 parent 46bcaee commit e0dbd1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/Moose/Meta/Attribute/Native/Trait/Array.pm
Expand Up @@ -78,10 +78,13 @@ This method does not accept any arguments.
=item * B<elements>
Returns all of the elements of the array as an array (not an array reference).
In list context, returns all of the elements of the array as a list.
my @option = $stuff->all_options;
print "@options\n"; # prints "foo bar baz boo"
In scalar context, returns the number of elements in the array.
my @options = $stuff->all_options;
print "@options"; # prints "foo bar baz boo"
print scalar $stuff->all_options; # prints 4
This method does not accept any arguments.
Expand Down
5 changes: 4 additions & 1 deletion lib/Moose/Meta/Attribute/Native/Trait/Hash.pm
Expand Up @@ -102,7 +102,10 @@ This method does not accept any arguments.
=head2 elements
Returns the key/value pairs in the hash as a flattened list..
In list context, this returns the key/value pairs in the hash.
In scalar context, this returns the count of keys plus values. In other words,
it's the same as L<keys> times two.
This method does not accept any arguments.
Expand Down

0 comments on commit e0dbd1d

Please sign in to comment.