From 4fba789fbb82fb2c120c7f3199e75da3c0a279bd Mon Sep 17 00:00:00 2001 From: Jan-Olof Hendig Date: Wed, 15 Jun 2016 22:16:53 +0200 Subject: [PATCH] Added docs for Baggy.pickpairs --- doc/Type/Baggy.pod | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/Type/Baggy.pod b/doc/Type/Baggy.pod index cb3e3f603..89a32e75d 100644 --- a/doc/Type/Baggy.pod +++ b/doc/Type/Baggy.pod @@ -47,7 +47,25 @@ no effect on subsequent C 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 or a C of Cs depending on the version of the method +being invoked. Each C 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 of the invocant, then all element/weight Cs from +the invocant are returned in a random sequence. + +Note that each C invocation maintains its own private state and has +no effect on subsequent C invocations. + + my $breakfast = bag ; + say $breakfast.pickpairs; # eggs => 1 + say $breakfast.pickpairs(1); # (bacon => 3) + say $breakfast.pickpairs(*); # (eggs => 1 bacon => 3) =head2 method roll