Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
don't return Nil from listy .pick or .roll
  • Loading branch information
TimToady committed May 9, 2015
1 parent ba654d8 commit 8139c05
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/List.pm
Expand Up @@ -187,7 +187,7 @@ my class List does Positional { # declared in BOOTSTRAP
fail X::Cannot::Infinite.new(:action<.pick from>) if self.infinite;

my Int $elems = self.elems;
return unless $elems;
return () unless $elems;

my Mu $picked := nqp::clone($!items);
my int $i;
Expand All @@ -206,7 +206,7 @@ my class List does Positional { # declared in BOOTSTRAP
fail X::Cannot::Infinite.new(:action<.pick from>) if self.infinite;

my Int $elems = self.elems;
return unless $elems;
return () unless $elems;

my Mu $rpa := nqp::clone($!items);
my int $i;
Expand All @@ -225,7 +225,7 @@ my class List does Positional { # declared in BOOTSTRAP
## of the list, resulting in an O(n) algorithm.

my Int $elems = self.elems;
return unless $elems;
return () unless $elems;

my int $n = number > $elems ?? $elems !! number.Int;
return nqp::atpos($!items,$elems.rand.floor) if $n == 1;
Expand Down Expand Up @@ -385,7 +385,7 @@ my class List does Positional { # declared in BOOTSTRAP
multi method roll(Whatever) {
fail X::Cannot::Infinite.new(:action<.roll from>) if self.infinite;
my $elems = self.elems;
return unless $elems;
return () unless $elems;

my $list := gather loop {
take nqp::atpos($!items,$elems.rand.floor);
Expand All @@ -398,7 +398,7 @@ my class List does Positional { # declared in BOOTSTRAP

fail X::Cannot::Infinite.new(:action<.roll from>) if self.infinite;
my $elems = self.elems;
return unless $elems;
return () unless $elems;

my int $n = number.Int;
return nqp::atpos($!items,$elems.rand.floor) if $n == 1;
Expand Down

0 comments on commit 8139c05

Please sign in to comment.