EGL supports the following kinds of literals: character, numeric, and list.
myString string = "EGL is said to be \"elegant\" because it is.";
As shown, you can use an escape character to include double quotes in the string.
myString string(3) = "EGL";
Numeric variables consist of digits and can include a decimal point, a plus or minus sign, and the letter "E" or "e" for scientific notation.
myFloat FLOAT = 2.539e7;
You can specify the type of a numeric literal by adding a character, as shown next.
Literal type | Character to append | Example |
---|---|---|
smallint | i | mySmallInt smallInt = 123i; |
bigint | I | myBigInt bigInt = 123I; |
smallfloat | f | mySmallFloat smallFloat = 12.34f; |
float | F | myFloat float = 12.34F; |
A list literal consists of a pair of brackets that contains a comma-separated list of literals (including other list literals) or expressions (including lists). Each list literal has a type, and can be used anywhere an array of the given type is allowed, for instance, as an initializer for an list. The next table gives examples.
Array literal | Type |
---|---|
[ 1i, 2i, 3i ] | smallInt[] |
[ "hi", "Mom" ] | string[] |
[ new myRecord, new myRecord ] | myRecord[] |
[ (myPay < 0), (myPay > 0) ] | boolean[] |
[ [ 1, 2 ], [ 3, 4 ] ] | int[][] |
[ 3, "cow", [ 4.5, 6.7 ] ] | any[] |
If the types of the elements in the list literal differ, the element type is ANY. The elements in the array do not need to be assignment compatible with one another.