Swift Tutorial - Swift Constants/Variables






Constants

The following code creates a constant and stores the string "Hello World" in a constant named s1.

let s1:String = "Hello World"

The first part of the constant declaration is the let keyword.

The let keyword is used to define a constant.

The next part is the constant name s1.

You also have the type declaration :String.

Variables

Variables use the var keyword instead of the let keyword to declare.

Variable values can change.

var s2:String = "Hello World"
s2 = "Hola Mundo"