Soplang Logo
Soplang

Operators

Arithmetic, comparison, and logical operators in Soplang, with examples and precedence rules.

Operators in Soplang

Soplang supports arithmetic, comparison, and logical operators.

Arithmetic Operators

Use these operators with integers (abn) and floating-point numbers (jajab).

OperatorMeaningExample
+Additiona + b
-Subtractiona - b
*Multiplicationa * b
/Divisiona / b
%Moduloa % b
arithmetic_operators.sop
abn a = 10
abn b = 3
qor("Wadarta: " + (a + b))
qor("Hadhaaga: " + (a % b))

Comparison Operators

Comparison operators test equality and ordering between values.

OperatorMeaningExample
==Equala == b
!=Not equala != b
>Greater thana > b
<Less thana < b
>=Greater or equala >= b
<=Less or equala <= b
comparison_operators.sop
door a = 5
door b = 10
qor("a == b: " + (a == b))
qor("a < b: " + (a < b))

Logical Operators

Logical operators combine or negate boolean conditions.

OperatorMeaningExample
&&Logical AND(a > 5) && (b < 10)
||Logical OR(a < 5) || (b > 3)
!Logical NOT!(a == b)
logical_operators.sop
abn x = 5
abn y = 10

bool isInRange = (x > 3) && (y < 15)
bool isMismatch = !(x == y)
qor("Is in range: " + isInRange)
qor("Mismatch: " + isMismatch)

Operator Precedence

Operators have the following precedence, from highest to lowest:

  1. Unary: !, -
  2. *, /, %
  3. +, -
  4. Comparison: ==, !=, >, <, >=, <=
  5. Logical: &&, ||

&& and || have equal precedence

Many languages give && higher precedence than ||. In Soplang, both have equal precedence and group from left to right: run || been && been evaluates to been. Use parentheses when combining them, such as run || (been && been).

String Concatenation

+ also joins strings. When either operand is a string, the other value, such as a number, boolean, or list, is converted to text.

string_concat.sop
qor("Soplang " + "waa fiican")   // Soplang waa fiican
qor("Da'da: " + 25)               // Da'da: 25

// Store the result of a comparison
door natiijo = 5 > 3
qor(natiijo)                      // run

Division (/) can produce a fractional result: 10 / 4 is 2.5. Division by zero (x / 0) produces a runtime error.

On this page