Operators
#
Arithmetic OperatorsIn LemonScript, there are a variety of operations such as +
, -
, *
and /
. Here is a list of all of them and what they do:
+
- The plus operator can add a number or string to another number or string. For example5 + 6
will return11
, and"Hi I'm " + "Bob"
will returnHi I'm Bob
. If either value is a string, it'll treat both values a string.-
- The minus operator can only subtract a number from another. For example13.6 - 7.2
will return6.4
.*
- The multiplication operator can either multiply two numbers, for example4 * 7
will return28
, or a string multiplied by a number, for example"hi" * 3
will returnhihihi
./
- The divide operator can only divide a number from another number, for example12 / 3
will return4
.%
- The modulus operator returns the remainder when a number is divided by another number. For example,14 % 4
will return2
because the highest multiple of 4 is 12, and14 - 12
is 2.^
- The caret operator exponentializes a number to another number. For example2 ^ 3
will return8
. Other types will throw an error.
#
Comparison OperatorsThese operators return a boolean value (true or false) when comparing two expressions.
<
or<=
- The less or less or equal than operators check two numbers to another, and if they're less or equal. For example,4 < 5
returnstrue
, but14 < 8
isfalse
. The<=
operator does the same thing, but also checks for equality, i.e6 <= 6
istrue
.>
or>=
- The greater or greater or equal than operators check two numbers to another, and if they're greater or equal. For example,12 > 6
returnstrue
, but14 > 12
isfalse
. The>=
operator does the same thing, but also checks for equality.==
- The equals operator checks if two values have the same type, and the same value. For example,"hello" == "hello"
is true, but"5" == 5
or23 == 41.2
are not.