This is the documentation for the development version.
There are no official binaries for it; build it from the source code in git.
Download links on these pages work only after the release.
For the current release, see version 7.0.
range
range(start, end) ⇒ Range range(start, end, step) ⇒ Range range(end) ⇒ Range:: Creates a Range object for iteration.
+ .Parameters
start |
Numeric |
Start value (inclusive). If only one argument is provided, start defaults to 0 and the argument becomes end |
end |
Numeric |
End value (exclusive) |
step |
Numeric |
Step value. Optional, defaults to 1. A negative step counts down from |
+ .Return
Range object that is iterable and can be used in for-each loops.
+
// Create range from 0 to 9
for (i : range(10)) {
println(i); // prints 0, 1, 2, ..., 9
}
// Create range from 5 to 9
for (i : range(5, 10)) {
println(i); // prints 5, 6, 7, 8, 9
}
// Create range from 0 to 10 with step 2
for (i : range(0, 10, 2)) {
println(i); // prints 0, 2, 4, 6, 8
}