Type conversion
The ARL rule language allows you to convert values from one data type to another.
Implicit type conversion
Primitive types support implicit conversions also known as widening conversions.
Widening conversions mean that you convert smaller types to larger types:
bytetoshort,int,long,float, ordoubleshorttoint,long,float, ordoubleinttolong,float, ordoublelongtofloatordoublefloattodouble
Note: Converting
int to float, or long to
float or double, can result in a loss of precision.Autoboxing and unboxing conversion
Autoboxing is the automatic conversion performed by the ARL compiler to convert primitive types
to their corresponding object wrapper classes. For example, converting an int to an
Integer, or a double to a Double.
If the conversion goes the other way, this is called unboxing.
Cast operator
Regular Java-like operators can be used to convert values from one type into another. For example:
int x = 20;
byte y = (byte)x;
As operator
Like in C#, the cast operator as can be used to perform conversions between
reference types or nullable types. For example:
Customer customer = person as Customer;