Skip to content

Expressions: Types

An expression result, or any intermediate value within an expression, has a type. The expression type system is modeled after the JSON data model.

Supported types

Type
Description
Example
stringSequence of characters"hello"
numberNumeric value2.1
nullUndefined value
booleanEither true or falsetrue
objectKey-value mapping. Each value can be of any valid type except lambda{a: 1, b: "c"}
arraySequence of values, each of any valid type except lambda[2, "hello", "world"]
lambdaFunction, which performs a computation based on its parameters.

A lambda value consists of the following parts: 
  • set of parameter declarations
  • closure containing all variables that are accessible to the lambda (including parameters and all other variables in enclosing scopes).
  • expression that defines how to compute the lambda result based on parameters. See also Lambda Constructors and Lambda Invocations.
(x)=>2*x

Type coercion

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 -->stringnumbernullbooleanobjectarray
string=Convert="null"="true" or "false"JSON repJSON rep
numberTry to convert=No=1 or 0NoNo
nullNoNo=NoNoNo
boolean=true=true if !0=false==true=true
objectNoNoNoNo=No
arrayNoNoNoNoNo=
Note:

Values of type lambda cannot be coerced to any type or from any type.