Comparative Operators

A comparative operator is an operator that takes in operands and returns a boolean.

Equal to (==) (===)

When you want to check if a value is equal to another value in osl, there's multiple levels of how to do it.

Case Insensitive

When you want to do an equals check for two values that is case and type insensitive, you can use ==

log "hello" == "Hello"
// this will return true

Case Sensitive

When you want to do an equals check for two values that is case and type sensitive, you can use ===

log "hello" === "Hello"
// this will return false

log "world" === "world"
// this will return true

Type Sensitivity is also a benefit of using ===

log "10" == 10
// this will return true

log "10" === 10
// this will return false

Greater than

You can check if a value is greater than another using the > operator. Greater than is always case insensitive when using strings

Less than

You can also do the inverse of greater than and check if a value is less than another using the < operator

Checking Contains

You can check if a value contains another value using

Ternary Operator (?)

The ? operator provides a shorthand way to write simple if-else statements. It takes three operands: a condition followed by two values, where the first value is returned if the condition is true, and the second value if it's false.

Inverting A Comparison

You can simply place a ! infront of any comparison below to make it do the opposite of the norm.

Last updated

Was this helpful?