range()
Return an opaque object that can be only be used in foreach statements.
range range(int stop)
range range(int start, int stop[, int step])
-
startmust be integer greater or equal to 0. Defaults to 0. -
stopmust be integer greater or equal tostart. -
stepmust be integer greater or equal to 1. Defaults to 1.
It cause the foreach loop to be called with the value from start included
to stop excluded with an increment of step after each loop.
Signature
(since 0.58.0)
# Return an opaque object that can be only be used in `foreach` statements
range range(
int [start], # The start of the range
int [stop], # The end of the range
int [step], # The loop increment
)
Example
# Loop 15 times with i from 0 to 14 included.
foreach i : range(15)
...
endforeach
The range object can also be assigned to a variable and indexed.
r = range(5, 10, 2)
assert(r[2] == 9)
Arguments
The function range() accepts the following positional arguments:
| Name | Type | Description | Tags |
|---|---|---|---|
start |
int |
The start of the range |
[optional]
|
stop |
int |
The end of the range |
[optional] |
step |
int |
The loop increment |
[optional]
|
The results of the search are