We just saw how to declare a variable in swift using the “var” keyword. Now we will learn how to declare constants in swift.
To declare constants in swift we make use of the “let” keyword. Constant is a set of value/values which cannot be changed at any time in the program. The constants lets you finalize a value. The following is the syntax for Declaring a variable as a constant.
let noOfMonths = 12
if we try to re-use the variable noOfMonths and re-assign a new value; we get an error as shown below.
Constants have similar property as Variables in Swift. Swift also Performs ‘Type inference’ implicitly. It can also perform ‘Type annotation’.
next we will learn about emoji variables.