-
Notifications
You must be signed in to change notification settings - Fork 2
Operators
Addition Can Be Performed On Integers, and Floats. If Using Addition Between two Strings, it will Concatenate them.
var a = 1;
var b = 2;
var c = (a + b);
print(a + b);
var a = "hello";
var b = "hi";
print(a + b);
Multiplication is Used in Integers, and Floats.
You can also multiply a string by a integer to duplicate it, but, if multiplying a string by a string, it will throw an error.
var a = 10;
var b = 20;
print(a * b);
var a = "hello";
var b = (a * 3);
print(b);
Division is used between Integers and Floats.
Returns float
as a Data Type.
var a = 10;
var b = 20;
print(a / b);
Floor Division is used between Integers and Floats. Always Returns int
as the Data Type.
Ignores Everything After the Decimal Point.
var a = 10;
var b = 20;
print(a // b);
Power is used between Integers and Floats.
var a = 10;
var b = 2;
print(a ** b);
Modulus is used between Integers and Floats. It Returns the Remainder after Dividing Two Numbers.
var a = 10;
var b = 2;
print(a % b);
-
==
(is equal to) -
>=
(greater than or equal to) -
<=
(less than or equal to) -
>
(greater than) -
<
(less than) -
!=
(not equal to)
-
+
(plus) -
-
(minus) -
!
(not) -
=
(set / assign)
Slicing allows you to extract parts of arrays or strings using the syntax:
array[start:stop:step]
-
start
: Starting index (optional, defaults to 0 for positive step, or length-1 for negative step) -
stop
: Ending index (optional, defaults to length for positive step, or -1 for negative step) -
step
: Step size (optional, defaults to 1)
All indices support negative numbers to count from the end of the sequence.
Examples:
Blue Lagoon.
A Pranav Verma Production.