Data Types and Operators
EasyBite is a dynamically typed language. You don’t need to declare the type of a variable — it is inferred from the value assigned using the to
keyword. The =
operator is not supported.
Data Types
Data Type | Description | Example |
---|---|---|
Number | Whole or decimal numbers | 10 , -3.5 , 0 |
String | Text enclosed in quotes | "Hello" , 'World' |
Boolean | Logical true or false | true , false |
Null | Represents empty or undefined value | null |
Array | Ordered list of values | declare arr[5] or arr[] |
Dictionary | Key-value mappings | { name: "Ali", age: 25 } |
ByteArray | Raw byte sequences | bytearray("ABC") |
Object | Instance of a class | new User() |
Examples
declare name
set name to "Ali"
declare age
set age to 25
declare scores[]
set scores to [80, 90, 100]
declare person
set person to { name: "Ali", age: 25 }
declare binary
set binary to bytearray("ABC")
declare student
set student to new Student()
Assignment
Use declare
to define a variable, and set
or to
to assign a value.
declare x
set x to 10
x to 20 // Reassign without `set`
declare arr[3]
set arr to [1, 2, 3]
declare user
set user to { name: "Fatima", age: 21 }
Arithmetic Operators
Operator | Name | Description | Example | Result |
---|---|---|---|---|
+ | Addition | Adds two numbers | 5 + 3 | 8 |
- | Subtraction | Subtracts one number from another | 10 - 4 | 6 |
* | Multiplication | Multiplies two numbers | 4 * 2 | 8 |
/ | Division | Divides one number by another | 8 / 2 | 4 |
remind | Modulus | Returns remainder | 7 remind 3 | 1 |
^ | Power | Raises number to power | 2 ^ 3 | 8 |
Examples
show(5 + 3) // 8
show(10 - 4) // 6
show(4 * 2) // 8
show(8 / 2) // 4
show(7 remind 3) // 1
show(2 ^ 3) // 8
Comparison Operators
Operator | Description | Example | Result |
---|---|---|---|
is / == | Equal | 5 is 5 , 5 == 5 | true |
is not / != | Not equal | 3 is not 4 , 3 != 4 | true |
> | Greater than | 6 > 3 | true |
< | Less than | 2 < 5 | true |
>= | Greater than or equal | 5 >= 5 | true |
<= | Less than or equal | 3 <= 4 | true |
is in | Exists inside a collection | "Ali" is in names | true |
Examples
show(5 is 5) // true
show(4 == 4) // true
show(3 is not 4) // true
show(6 != 5) // true
show(9 > 2) // true
show(2 < 5) // true
show(10 >= 10) // true
show(4 <= 7) // true
declare names[]
set names to ["Ali", "Maryam", "Zainab"]
show("Ali" is in names) // true
Logical Operators
Operator | Description | Example | Result |
---|---|---|---|
and | Logical AND | true and false | false |
or | Logical OR | true or false | true |
not | Logical NOT | not true | false |
Examples
show(true and true) // true
show(true and false) // false
show(false or true) // true
show(not false) // true
Type Casting Operator
Operator | Description | Example | Result |
---|---|---|---|
as | Converts one type to another | "25" as number | 25 |
Examples
declare x
set x to "123"
declare y
set y to x as number
show(y) // 123
Ternary Operator
Ternary expressions allow inline conditional assignment using:
if condition then value1 else value2
Examples
declare age
set age to 17
declare status
set status to if age >= 18 then "Adult" else "Minor"
show(status) // Output: Minor
Dictionary Access
declare user
set user to { name: "Maryam", role: "admin" }
show(user.name) // Maryam
show(user["role"]) // admin
Full Combined Example
declare a
set a to 5 ^ 2
show(a) // 25
declare b
set b to 10 remind 3
show(b) // 1
show(7 == 7) // true
show(5 != 3) // true
show(6 > 2) // true
declare passed
set passed to true and not false
show(passed) // true
declare list[]
set list to ["apple", "banana", "orange"]
show("banana" is in list) // true
declare score
set score to 75
declare grade
set grade to if score >= 70 then "Pass" else "Fail"
show(grade) // Pass
declare s
set s to "456"
declare n
set n to s as number
show(n) // 456
Notes
- Use
declare
andto
for assignment. =
is not supported.==
and!=
are supported for equality.remind
is used instead of%
.^
is used for exponentiation.- Use
as
for type conversion. if ... then ... else
is the ternary syntax.