Skip to content

Commit

Permalink
Get RangeIter to handle the Str cases properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Feb 20, 2010
1 parent abb98b4 commit 71d8848
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/RangeIter.pm
@@ -1,4 +1,11 @@

multi sub RangeIterCmp($a, $b) {
$a cmp $b;
}

multi sub RangeIterCmp(Str $a, Str $b) {
$a.chars <=> $b.chars || $a cmp $b;
}

class RangeIter is Iterator {
has $!value;
Expand All @@ -10,12 +17,12 @@ class RangeIter is Iterator {
:max($r.max),
:excludes_max($r.excludes_max));
}

method get() {
my $current = $!value;
unless $!max ~~ ::Whatever {
if $current after $!max
|| $!excludes_max && !($current before $!max) {
if RangeIterCmp($current, $!max) == 1
|| $!excludes_max && RangeIterCmp($current, $!max) != -1 {
return EMPTY;
}
}
Expand Down

0 comments on commit 71d8848

Please sign in to comment.