You have to declare variables and constants before using it. Constants are declared by using let keyword and variables by var keyword.
In Swift, you declare variables using the var
keyword and constants using the let
keyword. Here’s an example of how you would declare a variable and a constant:
var myVariable = 10
let myConstant = 20
In this example, myVariable
is a variable whose value can be changed later in the code, while myConstant
is a constant whose value cannot be changed once it’s set.