Vars

Vars is the last reference type that you will learn about. Vars are like global objects in other programming languages. They are created at the top level of a namespace. Vars provide a mechanism to refer to a mutable storage location that can be dynamically rebound (to a new storage location) on a per-thread basis.

We can create a var by using a special form of def, as follows:

(def player-max-level 100)

If we want to obtain its value, we call the var, as follows:

player-max-level

We then get the value shown in the following output:

=> 100