Types
DLiteScript is a statically typed language, meaning every variable must have a declared type.
Basic Types
Number
The number
type represents numeric values, including both integers and floating-point numbers.
Examples:
|
|
String
The string
type represents text data. Strings are enclosed in double quotes.
Examples:
|
|
Bool
The bool
type represents boolean values: true
or false
.
Examples:
|
|
Null
The null
value represents the absence of a value.
It’s used in comparisons and as a return value,
but cannot be directly assigned to typed variables.
When variables are declared without initialization, they receive zero values instead:
number
defaults to0
string
defaults to""
bool
defaults tofalse
- Arrays default to
[]
Examples:
|
|
Special Types
Any
The any
type accepts values of any type.
This provides flexibility when the specific type isn’t known at compile time.
Examples:
|
|
Error
The error
type is used for error handling and represents error values.
Examples:
|
|
Composite Types
Arrays
Arrays are declared using square brackets []
followed by the element type.
All elements in an array must be of the same type.
Syntax:
[]number
- Array of numbers[]string
- Array of strings[]bool
- Array of booleans
Examples:
|
|
Type Conversion
DLiteScript does not perform implicit type conversion. Types must match exactly in assignments and operations.
|
|