It is important to know the differences between a variable and a constant. These are things you will use every day and luckily, it’s really simple to understand. Choosing the correct declaration (var or let) when creating objects makes your code safer and it encourages you to know your code inside and out.
Declaring an object as a variable or constant is not only for integer values (as shown on this page), the same also apply to other types like strings, integers, arrays and dictionaries.var
In Swift, var means variable. A variable is an object that can be mutated, or changed.Example:
In our example code below, we create an object named interestRate. We declare it as a variable by adding “var” before the name. Because we declared it a variable, this object can be updated whenever our interest rate changes.