Operators

Introduction to Operators in Flowata

Operators are the building blocks that enable you to perform various types of operations in Flowata, from simple arithmetic calculations to complex logical evaluations. Understanding operators is crucial for writing efficient and effective formulas. In Flowata, you'll find a rich set of operators that are designed to be both powerful and intuitive.

This document will guide you through the different categories of operators available in Flowata:

Whether you're a beginner looking to understand the basics or an experienced developer seeking to optimize your formulas, this guide will provide you with the insights you need to make the most out of Flowata's operator set.

Concatenation

The concat function or the & operator can be used to concatenate strings.

print(concat("Hello", " ", "world!")); // Output: Hello world!
print("Hello" & " " & "world!"); // Output: Hello world!

Arithmetic Operators

Flowata provides both word-based functions and operator symbols for arithmetic operations.

Word-based functions:

Operator symbols:

print(add(2, 3)); // Output: 5
print(subtract(10, 4)); // Output: 6
print(multiply(5, 2)); // Output: 10
print(divide(15, 3)); // Output: 5
print(modulo(10, 3)); // Output: 1
print(power(2, 3)); // Output: 8

print(2 + 3); // Output: 5
print(10 - 4); // Output: 6
print(5 * 2); // Output: 10
print(15 / 3); // Output: 5
print(10 % 3); // Output: 1
print(2 ^ 3); // Output: 8

Comparison Operators

Flowata provides both word-based functions and operator symbols for comparison operations.

Word-based functions:

Operator symbols:

print(greaterThan(5, 3)); // Output: true
print(lessThan(7, 4)); // Output: false
print(greaterEqual(8, 8)); // Output: true
print(lessEqual(10, 12)); // Output: true
print(equals("hello", "world")); // Output: false
print(notEquals(5, 5)); // Output: false

print(5 > 3); // Output: true
print(7 < 4); // Output: false
print(8 >= 8); // Output: true
print(10 <= 12); // Output: true
print("hello" == "world"); // Output: false
print(5 != 5); // Output: false

Logical Operators

Flowata provides both word-based functions and operator symbols for logical operations.

Word-based functions:

Operator symbols:

print(and(true, false)); // Output: false
print(or(true, false)); // Output: true
print(not(true)); // Output: false

print(true && false); // Output: false
print(true || false); // Output: true
print(!true); // Output: false

Index Accessors

Index accessors are a powerful tool in Flowata that allow you to directly access specific elements within arrays, objects, and other data structures. Unlike the dotPath function, when using index accessors directly, you can utilize variables and string keys without any special formatting.

Using Index Accessors with Arrays

For arrays, you can access elements by their position:

setLocal(myArray, [10, 20, 30, 40]);
print(myArray[2]); // Output: 20

If you have a variable that holds a position, you can use it directly:

setLocal(position, 3);
print(myArray[position]); // Output: 30