Type conversion

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center?Ā Click hereĀ !

Contents

General Rules

Type conversion is usually done when using the attrib (=) operator between variables of different types. This page refers to the automatic type conversion, and not the one you obtain using the cast operator.

Ā 

The types convertible to a target type are listed in the table below:

Target TypeConvertible typesAdditional Information / Examples
numberstring"1" to 1
stringALLĀ 
booleanstring, number

"true" to true

value of number != 0

datestring, numberContructing a date from number assumes the number is a "to millis" representation of a date
intervalstring, number

Constructing a date from number assumes the number is a "to millis" representation of an interval

60000 to "1m"

"120m" (string) to "2h" (interval)

When converting a string to an array type, the string is first transformed to a string[] by splitting it at every "|" character, and then the conversion is done from string []Ā  to the target type array.

The conversion from string to a target type is done by parsing the string as a text representation of the target type.

Converting arrays

Converting arrays of different types is possible if the element types (inner type of the array) are convertible according to the the rules explained on this page. For example you can cast a number[] to a string[] because number is convertible to string, however you cannot convert a date[] to an interval[] because date cannot be converted to interval.

Converting structures

Structures can only be converted directly toĀ string or an array type. Converting a structure to an array requires that each field of the structure is convertible to the element type (inner type) of the array.

It may be possible for certain structures to be convertible to other types by using one or more intermediate types, however this is not done implicitly and users are required to use explicit casting in such cases. For example, a structure containing a single number field may be converted to a number by first casting it to a string then the resulting string to a number.

Casting a structure to a string is equivalent to casting to a string [] and then the resulting array to string.

Ā 

Ā 

Calling routines

When calling a routine or UDR, if the given parameter's type is not the same as what the routine is expecting, the conversion will be done automatically according to the rules above.

function f(string s){
	print(s);
}
f(2); //number automatically converted to string
f(true); // boolean automatically converted to string

Compatibility

These conversions cover the functionality implemented before v2.5, so they are backwards compatible.