Simple types
The type of a variable delineates the set of values it can hold. In this document, you will learn about the different simple types a Flow variable can have.
number
The number type can hold hold numeric values, including both integers and floating-point. Number values are written in decimal representation, using the point character to separate the integer and fractional parts.
// Example: Create three variables of type number
let x = 1 + 2;
let y = 0.5;
let z = -1;
text
The text type, known as "string" or "varchar" in other languages, can hold variable-length sequences of Unicode characters. Literal text values can be written using either single or double quote characters.
A text literal that begins with a double quote may contain single quote characters. The converse is also true.
// Example: Declare two variables of type text
let country = "Netherlands";
let city = 'Rotterdam';
A literal surrounded by the backquote (`) character is known as a template literal. In a template literal, expressions can be inserted within curly braces.
// Example: A template literal
let country = "Japan";
return `The name of the country is {country}.`;
// returns "The name of the country is Japan."
Template literals, unlike single and double quoted literals, may also contain line breaks.
boolean
The boolean type represents a truth value. A variable of type boolean can only be assigned the values true or false.
// Example: Declare two variables of type boolean
let x = true;
let y = false;
Boolean values are often used in conjunction with boolean operators.
datetime
The datetime type represents a calendar date and time of day. Unlike numbers, texts and booleans, datetime values have no special literal syntax. Instead, you typically receive them from a Date input, or work with them programmatically using the now function, the date function or any of the functions in the DateTime module.
// Example: Declare a variable of type datetime
let currentDateAndTime = now();
binary
The binary type represents unintepreted variable-length binary data such as an image, an encoded block of text or a PDF document. Binary variables typically orignate from a File gallery or the HTTP module. There is no literal syntax for binary values.
primitive
A value with the primitive type may be either number, text, boolean, datetime, binary or null. Type checking is relaxed for such values: you can freely use a value of type primitive in any situation where a number, text, boolean, etc. is called for. However, the actual value must be compatible with the requested type, or the application will fail at runtime.
// Example: create a function which calculates the square of a number.
// Then, pass two values of type primitive into it. The second call will fail.
function square(x: number) => x * x;
let x: primitive = "1";
let y: primitive = "this is definitely not a number";
// ERROR: This will fail because "y" cannot be converted to a number.
return square(x) + square(y);
Last updated
Was this helpful?