Swift is a type-safe language and is also based on the C language
Some types of C language are also practical, but the difference is that Swift declares variables and constants to be different
Let: used to modify constants, Var to modify variables
e.g:
Let num=111
var num2=222
NUM=12 will get an error.
Num2=123 will be able to pass normally.
In the absence of a fixed type, the type of let and Var declarations is omnipotent, and the system determines the type of the parameter based on the following parameter types
We can use the following method to declare a variable and constant of type
Let Num:int =111
Let num2:string = "222"
The first letter of a property must be capitalized!
and a magical range operator.
A.. <b the number from A to B, not including b
A...B the number from a to B, including b
Swift also provides an optional declaration optionals
var num:string?
Equivalent to declaring a nil string
Swift First Experience