Skip to main content

Operators

Operators are special symbols used to perform calculations, compare values, and evaluate expressions in TinyPanda.

Arithmetic Operators

TinyPanda supports standard mathematical operators for performing calculations on integers. It correctly respects operator precedence (multiplication and division are evaluated before addition and subtraction).

OperatorOperationExampleResult
+Addition5 + 510
-Subtraction10 - 37
*Multiplication4 * 28
/Division10 / 25

Comparison Operators

Comparison operators look at two values and evaluate down to a boolean literal (true or false). These are highly useful for controlling flow inside conditional blocks.

OperatorDescriptionExampleResult
==Equal to5 == 5true
!=Not equal to5 != 3true
>Greater than10 > 2true
<Less than4 < 1false
>=Greater than or equal to5 >= 5true
<=Less than or equal to3 <= 5true
echoln(10 > 5); // Outputs: true
echoln(10 == 5); // Outputs: false

Prefix Operators

Prefix operators are placed before a single value to invert it or change its state. TinyPanda supports the ! (bang/exclamation) operator to invert boolean values.

OperatorDescriptionExampleResult
!Invert / NOT!falsefalse
echoln(!"name"); // Outputs: false
echoln(!1); // Outputs: false
echoln(!true); // Outputs: false
echoln(!false); // Outputs: true

You can learn about truthy and falsy values in TinyPanda here.

info

TinyPanda checks your data type on the left and right side of an operator. Operations or comparisons can only be performed if the data types on both sides matches.

Mixing mismatched types across an operator will instantly halt execution with a runtime error.

// Both of these will throw a runtime error!
iff (10 > "abc") { ... }
bamboo foo = "bar" + 100;