Casting
Casting refers to bypassing of the type validation and assigning data types that aren’t necessarily compatible.
For example, you may want to assign an integer value to a string. In such cases, you can use a conversion operation like the following one:
<conversionTypeName> ( <valueToConvert> )
where:
conversionTypeName
is the data type you want to assign to a value.
Here are some examples of casting or conversion operations:
-
string(myIntDO
) -
int(myStringDO)
-
duration(myStringDO)
Note:
You can only cast to primitive data types. Therefore, theconversionTypeName
variable accepts only primitive types as valid values.
WARNING:
Assigning values that are incompatible results in runtime errors. Even though some preliminary checks are performed on conversions to prevent incompatible castings (for example, a conversion from 'Boolean' to 'date'), all conversions are generally considered unsafe because there’s no extra processing performed when applying them.