remove closures from code
[nit.git] / lib / standard / collection / range.nit
index f356c6f..1c3e934 100644 (file)
@@ -42,17 +42,6 @@ class Range[E: Discrete]
 
        redef fun iterator do return new IteratorRange[E](self)
 
-       redef fun iterate
-               !each(e: E)
-       do
-               var c = _first
-               var l = _last
-               while c <= l do
-                       each(c)
-                       c = c.succ
-               end
-       end
-
        redef fun length
        do
                var nb = _first.distance(_after)
@@ -100,3 +89,11 @@ class IteratorRange[E: Discrete]
                _item = r.first
        end
 end
+
+redef class Discrete
+       # Returns the range from 0 to `self-1`, is used to do:
+       #
+       #    for i in 3.times do print "Cool"
+       #    for i in 100.times do print "{i}/100"
+       fun times: Range[OTHER] do return new Range[OTHER](0, self-1)
+end