Range Types

A range is an Integer type that is limited to a range of specific values. It is expressed simply as a numerical start and end value, connected with two dots in between:

var x: 0..100;

Internally, Range types are stored ase on of the regular Integer types supported by Oxygene. The compiler will automatically pick the best matching type to fit the whole range (e.g. an Int64 if the range exceeds the scope of 32-bit, etc).

If the "Range Checks" Compiler Option is on, the compiler will also enforce range checks when assigning values from and to a range type variable. Constant assignments will always be range-checked at compile time;

x := 35; // ok
x := 210; // compiler error

See Also