Variables & Scope
Variables store values. Djazair is dynamically typed, meaning variables can hold any type of value and change types over time.
Declaration
Declare variables using let:
let username = "Riyadh"
let age = 30
let balance = 200.50
# Reassignment
balance = 450.75
Scoping Rules
Djazair uses lexical block scoping. Variables declared inside a block (such as an if block, loop, or function body) are local to that block and cannot be accessed outside of it:
let x = 10
if x > 5
let y = 20 # local to this if-block
print(x + y) # => 30
end
# print(y) # Error: y is not defined!