Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Variables

itevie edited this page Sep 13, 2023 · 3 revisions

Variables in Zephyr work mostly like every other language.

Creating variables

Creating variables is done using the var or const keyword, examples are:

var a = 2; // Creates a variable called "a" with a value of 2 (int)
var int a = 2; // Same as above, though explicitly defining the type and the variable will always be an int
const a = 2; // Same as 1st but the variable can never be reassigned
var int? a = 2; // Same as second, but it can be either null or int type

Using variables

Variables can be used by just using their name somewhere else, for example, adding 2 numbers:

var a = 2;
var b = 3;

var c = a + b; // c = 5
Clone this wiki locally