Skip to content

Commit

Permalink
Added docs for Baggy.pickpairs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Olof Hendig committed Jun 15, 2016
1 parent 9765cb3 commit 4fba789
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion doc/Type/Baggy.pod
Expand Up @@ -47,7 +47,25 @@ no effect on subsequent C<pick> invocations.
=head2 method pickpairs
=comment TODO
Defined as:
multi method pickpairs(Baggy:D:) returns Pair:D
multi method pickpairs(Baggy:D: $count) returns List:D
Returns a C<Pair> or a C<List> of C<Pair>s depending on the version of the method
being invoked. Each C<Pair> returned has an element of the invocant as its key and the
elements weight as its value. The elements are 'picked' without replacement. If C<*>
is passed as C<$count>, or C<$count> is greater than or equal to the number of
L<elements|#method elems> of the invocant, then all element/weight C<Pair>s from
the invocant are returned in a random sequence.
Note that each C<pickpairs> invocation maintains its own private state and has
no effect on subsequent C<pickpairs> invocations.
my $breakfast = bag <eggs bacon bacon bacon>;
say $breakfast.pickpairs; # eggs => 1
say $breakfast.pickpairs(1); # (bacon => 3)
say $breakfast.pickpairs(*); # (eggs => 1 bacon => 3)
=head2 method roll
Expand Down

0 comments on commit 4fba789

Please sign in to comment.