x++ / Documents / Comparators

Table of Contents

Catalog

E

F

G

I

L

N

About

Comparators are symbols or keywords that compare two different variables or values and trigger a branch in the x++ thread. Each comparator has its functionality.

Expressions are segments in the code that creates a branch in the x++ thread. They are always made up of three components: the source, the comparator, and the target, and they are arranged like so:

<source> <comparator> <target>

For example:

5 == 5

Or:

"hello" in "hello world"

An expression cannot be used on its own, as it is not considered as an operator and thus not a valid statement. It is always accompanied by operators that take an expression as an argument. A classic example of this is the if operator:

if (5 == 5) "prt 'true'"

Any operator that uses an expression creates a branch, with true being the first branch and the second acts as an else. For example, the if operator creates a branch based on whether or not the expression is true:

if (5 == 10) "prt 'same'" "prt 'different'"

Documentation

Equal To

<source> == <target>

Checks if the two variables or values are equal to each other.

ParameterTypeDescription
SourceAnyThe variable or value that is being compared against
TargetAnyThe variable or value being compared to

Example:

if (5 == 5) "prt 'true'"

Not Equal To

<source> != <target>

Checks if the two variables or values are different from each other.

ParameterTypeDescription
SourceAnyThe variable or value that is being compared against
TargetAnyThe variable or value being compared to

Example:

if (5 != 10) "prt 'true'"

Less Than

<source> < <target>

Checks if the source is less than the target.

ParameterTypeDescription
SourceFloat or Integer or StringThe variable or value that is being compared against
TargetFloat or Integer or StringThe variable or value being compared to

Example:

if (5 < 10) "prt 'true'"

Less Than or Equal To

<source> <= <target>

Checks if the source is less than or equal to the target.

ParameterTypeDescription
SourceFloat or Integer or StringThe variable or value that is being compared against
TargetFloat or Integer or StringThe variable or value being compared to

Example:

if (5 <= 10) "prt 'true'"

Greater Than

<source> > <target>

Checks if the source is greater than the target.

ParameterTypeDescription
SourceFloat or Integer or StringThe variable or value that is being compared against
TargetFloat or Integer or StringThe variable or value being compared to

Example:

if (10 > 5) "prt 'true'"

Greater Than or Equal To

<source> >= <target>

Checks if the source is greater than or equal to the target.

ParameterTypeDescription
SourceFloat or Integer or StringThe variable or value that is being compared against
TargetFloat or Integer or StringThe variable or value being compared to

Example:

if (10 >= 5) "prt 'true'"

In

<source> in <target>

Checks if the source is in the target.

ParameterTypeDescription
SourceAnyThe variable or value that is being compared against
TargetAnyThe variable or value being compared to

Example:

if ("ello" in "Hello, world!") "prt 'true'"

Not In

<source> not in <target>

Checks if the source is not in the target.

ParameterTypeDescription
SourceAnyThe variable or value that is being compared against
TargetAnyThe variable or value being compared to

Example:

if ("bye" not in "Hello, world!") "prt 'true'"

Is

<source> is <target>

Checks if the source is a type of the target.

ParameterTypeDescription
SourceAnyThe variable or value that is being compared against
TargetStringThe variable or value being compared to

Example:

if (5 is "int") "prt 'true'"

Last Updated: March 9th, 2024 by iiPython

↑ Go To Top