The Is Equal To Comparison Operator checks whether two values are exactly the same. This operator evaluates to True if both values are identical, and False if they are different. It is one of the most commonly used comparison operators and is essential for checking equality in conditions.
The short syntax structure uses the == symbol:
VALUE == VALUEThe long syntax structure uses the words IS EQUAL TO:
VALUE IS EQUAL TO VALUEPRINTLN 5 == 5 // Displays "TRUE"
PRINTLN 5 == 10 // Displays "FALSE"
PRINTLN 0 == 0 // Displays "TRUE"PRINTLN 3.14 == 3.14 // Displays "TRUE"
PRINTLN 2.5 == 2.0 // Displays "FALSE"
PRINTLN 1.0 == 1.0 // Displays "TRUE"PRINTLN "Hello" == "Hello" // Displays "TRUE"
PRINTLN "Hello" == "World" // Displays "FALSE"
PRINTLN "abc" == "abc" // Displays "TRUE"PRINTLN TRUE == TRUE // Displays "TRUE"
PRINTLN TRUE == FALSE // Displays "FALSE"
PRINTLN FALSE == FALSE // Displays "TRUE"NEW INT x = 10
NEW INT y = 10
NEW INT z = 20
PRINTLN x == y // Displays "TRUE"
PRINTLN x == z // Displays "FALSE"NEW STR name1 = "Alice"
NEW STR name2 = "Alice"
NEW STR name3 = "Bob"
NEW BOOL areSame = name1 == name2
NEW BOOL areDifferent = name1 == name3
PRINTLN areSame // Displays "TRUE"
PRINTLN areDifferent // Displays "FALSE"NEW STR password = "secret123"
NEW BOOL isCorrect = password == "secret123"
PRINTLN isCorrect // Displays "TRUE"The Is Equal To operator is commonly used in If statements to check for specific values.
NEW STR answer = "yes"
IF answer == "yes"
PRINTLN "You agreed!"
ELSE
PRINTLN "You declined."
END IF
// Displays "You agreed!"NEW STR grade = "A"
IF grade == "A"
PRINTLN "Excellent!"
ELIF grade == "B"
PRINTLN "Good job!"
ELIF grade == "C"
PRINTLN "Satisfactory"
ELSE
PRINTLN "Needs improvement"
END IF
// Displays "Excellent!"NEW INT secretNumber = 42
NEW INT guess = 42
IF guess == secretNumber
PRINTLN "Correct!"
ELSE
PRINTLN "Try again"
END IF
// Displays "Correct!"The Is Equal To operator can control loop behavior by checking for specific conditions.
NEW INT counter = 1
WHILE counter <= 10
IF counter == 5
PRINTLN "Found 5!"
END IF
SET counter = counter + 1
END WHILENEW INT i = 1
NEW INT target = 7
WHILE i <= 10
PRINTLN "Checking: " .. i
IF i == target
PRINTLN "Target found!"
BREAK
END IF
SET i = i + 1
END WHILENEW INT x = 10
NEW INT y = 5
NEW BOOL result = ( x + y ) == 15
PRINTLN result // Displays "TRUE"NEW INT number = 8
NEW BOOL isEven = ( number % 2 ) == 0
PRINTLN isEven // Displays "TRUE"NEW INT a = 5
NEW INT b = 3
NEW INT c = 2
NEW BOOL balanced = ( a + b ) == ( c * 4 )
PRINTLN balanced // Displays "TRUE" ( 8 == 8 )NEW STR username = "admin"
NEW STR password = "pass123"
NEW BOOL validUser = ( username == "admin" ) && ( password == "pass123" )
PRINTLN validUser // Displays "TRUE"NEW STR color = "red"
NEW BOOL isPrimary = ( color == "red" ) || ( color == "blue" ) || ( color == "yellow" )
PRINTLN isPrimary // Displays "TRUE"It's critical to distinguish between the comparison operator ( ==, IS EQUAL TO ) and the assignment operator ( =, EQUAL TO ).
NEW INT x = 5 // EQUAL TO ( = ) assigns 5 to x
NEW BOOL result = x == 5 // IS EQUAL TO ( == ) checks if x equals 5
PRINTLN x // Displays "5"
PRINTLN result // Displays "TRUE"NEW INT age = 18
// Wrong: Using assignment in condition
// IF age = 18 // Syntax error!
// Correct: Using comparison in condition
IF age == 18
PRINTLN "Exactly 18!"
END IFNEW INT choice = 2
IF choice == 1
PRINTLN "Starting new game"
ELIF choice == 2
PRINTLN "Loading saved game"
ELIF choice == 3
PRINTLN "Exiting"
END IF
// Displays "Loading saved game"NEW STR status = "active"
IF status == "active"
PRINTLN "System is running"
ELIF status == "paused"
PRINTLN "System is paused"
ELIF status == "stopped"
PRINTLN "System is stopped"
END IF
// Displays "System is running"NEW INT i = 1
NEW BOOL found = FALSE
WHILE i <= 10
IF i == 7
SET found = TRUE
BREAK
END IF
SET i = i + 1
END WHILE
IF found == TRUE
PRINTLN "Number 7 was found!"
END IFNEW STR word1 = "Hello"
NEW STR word2 = "hello"
PRINTLN word1 == word2 // Displays "FALSE" ( case matters! )
PRINTLN word1 == "Hello" // Displays "TRUE"NEW INT x = 5
IF x = 5 // Syntax error! Use == for comparison
PRINTLN "x is 5"
END IF
// Correct:
IF x == 5
PRINTLN "x is 5"
END IFNEW INT x = 5
NEW STR y = "5"
PRINTLN x == y // Type error! Cannot compare Integer and StringNEW INT x = 5
NEW FLOAT y = 5.0
PRINTLN x == y // Type error! Cannot compare Integer and FloatNEW STR answer = "YES"
IF answer == "yes" // Will be FALSE due to case difference
PRINTLN "Confirmed"
END IF
// Correct: Match the case
IF answer == "YES"
PRINTLN "Confirmed"
END IF