From 71d8848e431c7902b4b31e78a3bf20381bbb5ee7 Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Fri, 19 Feb 2010 22:44:43 -0500 Subject: [PATCH] Get RangeIter to handle the Str cases properly. --- src/core/RangeIter.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/RangeIter.pm b/src/core/RangeIter.pm index 63222aac81c..fe96972b862 100644 --- a/src/core/RangeIter.pm +++ b/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; @@ -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; } }