Variable

Variable

> Tutorial

Variables are a fundamental concept in every programming language. They let you keep values in memory so you can reuse them in calculations.

Variables in LeekScript can hold several types of values:

Creating a variable

To use a variable, you first need to declare it. You declare it with the var keyword, like this:

// Declare the "enemy" variable var enemy

You can also give your variable a value at the same time, like this:

// Declare the enemy variable and assign it the nearest enemy var enemy = getNearestEnemy()

Using a variable

You can use variables in your code in several ways.

You can assign them a value (that is, make them "remember" this value in memory) with the assignment operator =:

// Declare myVariable var myVariable // Assign the value 5 to myVariable myVariable = 5