Data Types
Djazair features a rich set of built-in data types. It uses dynamic typing, but every value has a concrete runtime type.
Summary of Types
| Type | Sample Literals | Description |
|---|---|---|
| Number | 42, 3.14, 100_000 |
64-bit floating point number (double-precision). Underscores as thousands separators. |
| String | "hello", `multi` |
UTF-8 immutable text sequences. Supports multiline blocks and interpolation. |
| Bool | True, False |
Boolean truth values. Note the capitalization. |
| Null | Null |
Representing the absence of value. |
| Array | [1, "two", True] |
Dynamically sized ordered lists. Can hold mixed types. |
| Map | {"key": "value"} |
Hash tables associating keys with values. Keys can be any type. |
| Range | 1..5, 0 to 10 |
Inclusive sequences of numeric values, ideal for iteration. |
| Function | fn() ... end |
First-class callable closures. Can be stored and passed around. |
Type Casting
Convert between types using built-in casting functions:
let n = int(3.14) # => 3
let f = float("2.5") # => 2.5
let s = str(42) # => "42"
let b = bool(1) # => True
let x = num("10.5") # => 10.5 (generic number conversion)
Falsy values (convert to False): Null, False, 0, 0.0, empty string "", empty array [], empty map {}.
Querying Types
Use the built-in type() function or type assertions to inspect variables at runtime:
let val = 123.45
print(type(val)) # => Number
print(isNumber(val)) # => True
print(isString(val)) # => False