Merge: Nitg-g new NativeArray fix
[nit.git] / lib / standard / collection / range.nit
index 50fb761..29fa17e 100644 (file)
@@ -19,7 +19,7 @@ import abstract_collection
 class Range[E: Discrete]
        super Collection[E]
 
-       redef var first: E
+       redef var first
 
        # Get the last element.
        var last: E
@@ -238,14 +238,16 @@ private class DowntoIteratorRange[E: Discrete]
 end
 
 redef class Int
-       # Returns the range from 0 to `self-1`, is used to do:
+       # Returns the range from 0 to `self-1`.
        #
-       #     var s = new Array[String]
-       #     for i in 3.times do s.add "cool"
-       #     assert s.join(" ") == "cool cool cool"
+       #     assert 3.times == [0..3[
+       #     assert 10.times == [0..10[
+       #     assert ((-1).times).is_empty
        #
-       #     s.clear
-       #     for i in 10.times do s.add(i.to_s)
-       #     assert s.to_s == "0123456789"
+       # This can be usefull for loops:
+       #
+       #    var s = new Array[String]
+       #    for i in 3.times do s.add "cool"
+       #    assert s.join(" ") == "cool cool cool"
        fun times: Range[Int] do return [0 .. self[
 end