Intro
Variables are Containers for Storing Data
Kin Variables can be declared in 2 ways:
reka
By declaring variables by using reka keyword, you can change the value of the variable later in the program.
reka x = valueVariable x is declared and assigned a value of value but the value can be changed later in the program.
Also, you can declare a variable without assigning a value to it.
reka x;In this case, the variable
xis declared but not assigned a value. Note: You have to add semicolon (;) at the end of the statement.
ntahinduka
By declaring variable by using ntahinduka keyword, you can't change the value of the variable later in the program.
ntahinduka x = 10You can't change the value of variable x later in the program.
Note: You have to assign a value to a constant variable, so this won't work:
ntahinduka x; # This will throw an errorOptional type annotations
You can attach a type annotation after the variable name. Types are tokenized, parsed, and kept on the AST — they are not stripped. When a binding is annotated, Kin checks the value at declaration and on every later assignment.
reka age: umubare = 25
reka name: ijambo = "Keza"
ntahinduka PI: umubare = 3.14A mismatch raises a clear type error:
reka name: ijambo = 42
# Cannot assign a umubare to a ijambo, expected a ijambo instead.Unannotated bindings stay dynamic (you may reassign different kinds of values).
Required vs optional types
| Form | Meaning |
|---|---|
: type | Required — value must match the type; ubusa is rejected |
: type? | Optional — value may be the type or ubusa |
reka score: umubare = 10 # required number
reka maybe: umubare? = ubusa # optional number (null allowed)
reka later: ijambo?; # optional string, starts as ubusaAnnotation type names
Built-in names (Kinyarwanda):
| Name | Meaning |
|---|---|
umubare | number |
ijambo | string |
ukuri | boolean |
ubwoko_imiterere | plain object |
urutonde | array |
porogaramu_ntoya | function (user or native) |
_porogaramu_ntoya | native function (synonym of the above for annotations) |
ubusa | null |
You can also use named type aliases declared with ubwoko (object shapes,
unions, Fata). See Data Types.
reka list: urutonde = [1, 2, 3]
reka print: porogaramu_ntoya = tangaza_amakuruBuilt-in names
Kin also provides two globals you do not declare:
filename— a string: the path of the running.kinfile.KIN_INYANDIKOresolves relative paths against its directory.ikosa— a mutable name, initiallyubusa. Reserved as an error holder; the runtime does not currently write to it automatically.