Skip to main content

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 TypeDescriptionExample
NumberWhole or decimal numbers10, -3.5, 0
StringText enclosed in quotes"Hello", 'World'
BooleanLogical true or falsetrue, false
NullRepresents empty or undefined valuenull
ArrayOrdered list of valuesdeclare arr[5] or arr[]
DictionaryKey-value mappings{ name: "Ali", age: 25 }
ByteArrayRaw byte sequencesbytearray("ABC")
ObjectInstance of a classnew 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

OperatorNameDescriptionExampleResult
+AdditionAdds two numbers5 + 38
-SubtractionSubtracts one number from another10 - 46
*MultiplicationMultiplies two numbers4 * 28
/DivisionDivides one number by another8 / 24
remindModulusReturns remainder7 remind 31
^PowerRaises number to power2 ^ 38

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

OperatorDescriptionExampleResult
is / ==Equal5 is 5, 5 == 5true
is not / !=Not equal3 is not 4, 3 != 4true
>Greater than6 > 3true
<Less than2 < 5true
>=Greater than or equal5 >= 5true
<=Less than or equal3 <= 4true
is inExists inside a collection"Ali" is in namestrue

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

OperatorDescriptionExampleResult
andLogical ANDtrue and falsefalse
orLogical ORtrue or falsetrue
notLogical NOTnot truefalse

Examples

show(true and true)     // true
show(true and false) // false
show(false or true) // true
show(not false) // true

Type Casting Operator

OperatorDescriptionExampleResult
asConverts one type to another"25" as number25

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 and to 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.