Skip to content

Commit

Permalink
[core/Any-list.pm] deprecation note .pick :replace
Browse files Browse the repository at this point in the history
Prior to this change, the C<.pick> method accepted the :replace
parameter (which no longer applies and has been replaced by the
C<.roll> method) without complaining. Now it throws an error.
  • Loading branch information
Carl Masak committed Oct 24, 2010
1 parent acce294 commit d49eea2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/core/Any-list.pm
Expand Up @@ -163,7 +163,10 @@ augment class Any {
:excludes_max($excludes_max));
}

multi method pick($num is copy = 1) {
multi method pick($num is copy = 1, Bool :$replace) {
die "Option :replace is deprecated -- please use .roll"
if $replace;

my @l = @.list.Seq;

if ($num == 1) {
Expand All @@ -180,7 +183,10 @@ augment class Any {
}
}

multi method pick(Whatever) {
multi method pick(Whatever, Bool :$replace) {
die "Option :replace is deprecated -- please use .roll"
if $replace;

self.pick(Inf);
}

Expand Down Expand Up @@ -374,7 +380,9 @@ proto sub min($by, *@values) { @values.min($by); }
proto sub max($by, *@values) { @values.max($by); }
proto sub minmax($by, *@values) { @values.minmax($by); }
proto sub uniq(@values) { @values.uniq; }
proto sub pick ($num, *@values) { @values.pick($num); }
proto sub pick ($num, Bool :$replace, *@values) {
@values.pick($num, :$replace);
}
proto sub roll ($num, *@values) { @values.roll($num); }
proto sub map($mapper, *@values) { @values.map($mapper); }
proto sub kv(@array) { @array.kv; }
Expand Down

0 comments on commit d49eea2

Please sign in to comment.