To make use of. Let to declare constants, so that var to declare the variable.
? A constant value is not required at compile time, but you can only assign a value to it. So you can? Use constants to table? A value: You just have to decide, but you need to make it a lot of times.
NSLog ("--------------") var myvariable = myvariable = Mycontant = lable = "The Is"
The types of constants or variables must be the same as the values you assign to them.
However, when declaring a type is optional, when the declaration is assigned at the same time, the compiler will determine the type of its own initiative.
In the example of the upper plane, the compiler determines that myvariable is an integerbecause its initial value is an integer.
Assuming the initial value is not provided? enough information (or no initial value), then you need to declare the type after the variable,? Cut with a colon.
Values are never implicitly converted to other types. If you need to convert a value to another type, explicitly convert it.
Let width = 94; Let widthlable = lable + (string) (width) NSLog (String (), widthlable)
Is there a simpler way to convert a value to a string? Method: Write the value in parentheses and write it before the parentheses. a backslash.
Like what:
Let apples =3
Let oranges = 5
Let applesummary = "I hava\ (apples)apples"
Let fruitsummary = "I hava\ (apples+oranges)pieces of fruit"
To create an empty array or dictionary, use the Initialize syntax.
Let Emptarray = [String] ()
Let emptdictionary = Dictionary<String,Float> ()
Swift-definition and use of variables