Language Basics
Variables, types, operators, and fundamental language concepts.
Variables
Kria uses the set keyword to declare and assign variables.
Variables are dynamically typed and can hold any value.
Example
set x = 10
set y = 20
set sum = x + y
print(sum)
Variables persist during a session (in the REPL) or throughout a program. There are no special constants or immutable bindings.
Data Types
Kria has 7 primitive types:
- Number — Integers and floats (unified as "number")
- String — Text values with double quotes
- Boolean —
trueorfalse - Null — Represents undefined values
- Array — Mutable ordered collections
- Object — Key-value pairs
- Function — First-class functions and closures
Example
set name = "Kria"
set isActive = true
set value = null
print(name)
Arithmetic Operators
Kria supports standard arithmetic operations on numbers:
| Operator | Operation | Example |
|---|---|---|
+ |
Addition | 10 + 5 = 15 |
- |
Subtraction | 10 - 5 = 5 |
* |
Multiplication | 10 * 5 = 50 |
/ |
Division | 10 / 2 = 5 |
Example
set x = 10
set product = x * 20
print(product)
set quotient = 20 / x
print(quotient)
Comparison & Logical Operators
Compare values with relational operators. Combine conditions with logical operators:
| Operator | Meaning | Example |
|---|---|---|
== |
Equal to | 5 == 5 is true |
!= |
Not equal | 5 != 3 is true |
> |
Greater than | 10 > 5 is true |
< |
Less than | 5 < 10 is true |
>= |
Greater or equal | 10 >= 10 is true |
<= |
Less or equal | 5 <= 10 is true |
and |
Logical AND | true and false is false |
or |
Logical OR | true or false is true |
not |
Logical NOT | not false is true |
Example
set x = 10
set y = 20
if (x < y and y > 15) {
print("Both conditions true")
}
Type Checking
Use the type() built-in function to check a value's type at runtime:
print(type(42))
print(type("hello"))
print(type(true))
print(type(null))
Returns one of: "number", "string", "boolean",
"null", "array", "object", or "function".