An expression result, or any intermediate value within an expression, has a type. The expression type system is modeled after the JSON data model.
Type | Description | Example |
|---|---|---|
| string | Sequence of characters | "hello" |
| number | Numeric value | 2.1 |
| null | Undefined value | |
| boolean | Either true or false | true |
| object | Key-value mapping. Each value can be of any valid type except lambda | {a: 1, b: "c"} |
| array | Sequence of values, each of any valid type except lambda | [2, "hello", "world"] |
| lambda | Function, which performs a computation based on its parameters. A lambda value consists of the following parts:
| (x)=>2*x |
A value of one type may sometimes be converted to a value of another type. This is called type coercion. For example, in the expression @cos("22.3"), the cosine function is calculated over a string value; however since the string can be coerced into a number, the invocation will succeed. A value coerced into a boolean is called the truth-value.
The following table summarizes valid type coercions:
| To From --> | string | number | null | boolean | object | array |
|---|---|---|---|---|---|---|
| string | = | Convert | ="null" | ="true" or "false" | JSON rep | JSON rep |
| number | Try to convert | = | No | =1 or 0 | No | No |
| null | No | No | = | No | No | No |
| boolean | =true | =true if !0 | =false | = | =true | =true |
| object | No | No | No | No | = | No |
| array | No | No | No | No | No | = |
Note:
Values of type lambda cannot be coerced to any type or from any type.