Constants and Variables
Constants are named values that cannot be changed. They are declared using the let
keyword. Variables are named values that can be changed. They are declared using the var
keyword.
You can declare multiple constants or multiple variables on a single line, separated by commas:
Type Annotations
You can specify the type of a constant or variable by using a colon and the type name. For example, let pi: Double = 3.14
specifies that pi
is a constant of type Double
.
You can define multiple related variables of the same type on a single line, separated by commas, with a single type annotation after the final variable name: