Constant: Let product_constant = "iphone6"
Variable: var product_var = "iPad" // you do not need to declare the variable type. The type of the left-side variable is derived based on the value on the right.
Multiple variables can be defined together: var X1 = 30, X2 = "ABC"
You can specify the variable type precisely: var X1: Int = 27 // specify X1 as the int type
Println (X1) // print a single variable
Println ("X1 = \ (X1), X2 = \ (X2)") // print multiple variables
Initialization string
VaR emptystring1 = ""
VaR emptystring2 = string ()
VaR string3 = "ABC"
VaR string4 = string ("ABC ")
Comparison string
If (string3 = string4 ){
}
Connection string
Let str1 = "hello"
Let str2 = "world"
VaR str3 = str1 + str2 // str3 is equal to "Hello World"
Str1 + = str2 // str1 is equal to "Hello World"
String case-sensitive Conversion
Let lowerstr = "ABC"
Let upperstr = lowerstr. uppercasestring // uppercase for lowercase
Let lowerstr2 = upperstr. lowercasestring // lower the upper case
Tuples constants and variables
Let product1 = (20, "iphone6", 5888)
Let product_name = "iphone4s"
VaR product2 = (10, "\ (product_name)", 3888)
Println (product1) // (20, iPhone 6, 5888)
Println (product2) // (10, iPhone 4 s, 3888)