nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: Annotation lateinit
[nit.git]
/
lib
/
standard
/
collection
/
range.nit
diff --git
a/lib/standard/collection/range.nit
b/lib/standard/collection/range.nit
index
50fb761
..
29fa17e
100644
(file)
--- a/
lib/standard/collection/range.nit
+++ b/
lib/standard/collection/range.nit
@@
-19,7
+19,7
@@
import abstract_collection
class Range[E: Discrete]
super Collection[E]
class Range[E: Discrete]
super Collection[E]
- redef var first: E
+ redef var first
# Get the last element.
var last: E
# Get the last element.
var last: E
@@
-238,14
+238,16
@@
private class DowntoIteratorRange[E: Discrete]
end
redef class Int
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
fun times: Range[Int] do return [0 .. self[
end