Ranges

Range objects can be instantiated using the from..to syntax. Their primary purpose is to specify a range of unsigned integer numbers, such as indices for array slices and iteration ranges in for statements.

let array = [10, 20, 30, 40, 50];

array[1..3] == [20, 30];

for i in 7..12 {
    dbg(i); // Prints: 7, 8, 9, 10, and 11.
}

The from and to parts are any expressions that can be evaluated to unsigned integer numbers. The from value specifies the range's lower bound (inclusive), and the to value specifies the upper bound (exclusive).

The upper bound should be greater than or equal to the lower bound. Otherwise, the range is invalid, which will lead to runtime errors in most cases.

To construct a range with an "unlimited" upper bound, you can use the max built-in constant, which evaluates to the maximum unsigned integer number available on the current platform: 50..max.