by Example


To declare a variable use the keyword "var",
and the Swift compiler will infer its type.

You can explicitly specify a type

You can also do it in a single step

var name = "Joe Doe"

var age: Int; age = 21

var height: Int = 180

print("Name: \(name), Age: \(age) & Height: \(height)")
$ swift .swift
Name: Joe Doe, Age: 21 & Height: 180

Next: Constants