Skip to main content

Expressions / Operators

Operators in Smowcode are used to create mathematical expressions, equations and logic conditions to process numbers and strings.

Expressions can be used on-the-go anywhere in Smowcode. Assign it to any node property, if condition or loop conditions.

Expressions

Expressions are equations created using constant numbers, strings, arrays and variables. Eg. "My name is " + name, a + b, "My new value is " + ( ( 555 + x ) / (100 - y) ), a // b, a[i] % 2 == 0.

An expression can contain both numbers and strings of type flow or global. In case the node property expects a number and not a string, only numbers (variables/constants) should be included in the expression.

Constant strings are expressed in double quotes in an expression.

Operators

Following is the list of allowed operators.

OperatorOperationDescription
+Addition / String concatenationAdd 2 numbers or merge 2 strings
-SubtractionSubtract right operand from left operand
*MultiplyMultiple 2 numbers
/DivideDivides left operand with left operand but result an integer/float(decimal)
//DivideDivides left operand with left operand but result only an integer
%ModulusDivides left-hand operand by right-hand operand and results a remainder.
()BracketsAllows BODMAS
==Equal toCompare if 2 numbers if equal; results 0(false) / 1(true)
!=Not Equal toCompare if 2 numbers are not equal; results 0(false) / 1(true)
>Greater thanCheck if the left operand is greater than the right operand; results 0(false) / 1(true)
<Less thanCheck if the left operand is lesser than the right operand; results 0(false) / 1(true)
>=Less than or equalCheck if the left operand is greater than or equal to the right operand; results 0(false) / 1(true)
<=Greater than or equalCheck if the left operand is lesser than or equal to the right operand; results 0(false) / 1(true)
&&AND (Logical)If both of the two operands are non-zero, then the condition becomes true.
||OR (Logical)If any of the two operands are non-zero, then the condition becomes true.
&AND (Bitwise)Perform AND operation on each bit of the operands on its left and right.
|OR (Bitwise)Perform OR operation on each bit of the operands on its left and right.
^XOR (Bitwise)Perform XOR operation on each bit of the operands on its left and right.
<<Left ShiftThe left operands value is moved left by the number of bits specified by the right operand. New bits on the right will be 0s.
>>Right ShiftThe left operands value is moved right by the number of bits specified by the right operand. New bits on the left will be 0s.
error

We are yet to support the following operators:

  • ++ eg. i++.
  • -- eg. i--.
  • ?: eg. a ? 0 : 1
  • ! eg. !myCondition

:::