Variable var and let constants in Swift
First introduce the Var and let in Swift
(1) var is an abbreviated form of variable, which is the meaning of the variable and can be changed. Not a data type
Like what:
Note that you do not need to add semicolons after each statement
var i:double=10.0//I is referred to as a double, the variable name is followed by a colon var i = ten //Assuming that the type is not specified, the system will voluntarily infer the type I = 15//Correct wording according to your assignment
(2) Let is the meaning of a constant. Non-changing
Like what:
Let name:string = "Jhon"//defines the name as a string type, assuming that the program changes below will cause an error.name = "Hello"//Wrong wording
(3) Splicing string operation
Name+=string (i) outputs the Jhon10.0
+ = can do string concatenation operation
All Uinicode encoded characters can be declared and used as variable or const names.
Swift Learning--the use of variable var and let constants (i)