range: better nitunit on `Int::times`
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 25 May 2015 16:20:09 +0000 (12:20 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 25 May 2015 22:07:39 +0000 (18:07 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/standard/collection/range.nit

index 50fb761..c611ec1 100644 (file)
@@ -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