1. Data type
The first letter of the type is capitalized
Integer
Int
Int8 Int16 Int32 Int64
UInt8 unsigned number:
Float
Double
String
Array
Dictionary
Type inference
var num = 1//default integer
var d = 1.23//default double
Swift character
Double quotes 1 characters
Let C:character = "a"
var a:character
A = "a"
A = "LV"
2. Overflow
32-bit Maximum value
Let Overvalue:uint32 = Uint32.max
Overflow error
Let Overvalue2:uint32 = uint32.max+1
3. There is no implicit conversion between different data types can not directly calculate the need for strong turn
var d:double = 2.1
var int2:int
Strong value double to int
Int2 = Int (d)
4. Boolean values
Swift introduces True Boolean true flase and C + + similar
The IF expression must be a Boolean or the value of an expression is a Boolean
5. Tuples
/*
Tuple ("Xiaohong") multiple identical data types or different data types together this is a tuple
*/
Tuples do not need to be defined directly using
Let student = ("Zhang San", 23, 98.6)
println (Student)
println (student.0,student.1,student.2)
You can also define templates like this
Let Stu:(string,int,double) = ("Xiaohuang", 2,1.1)
Another form of extracting the value of a tuple
Let STU1 = (name: "Zhangsan", age:23)
println (Stu1.name)
Tuples are often used together with functions as parameters and return values equivalent to returning multiple Values C language can only return one value
6. Selectable values
/*
Optional value Swift is unique
Optionals has a value or no value like a Boolean value
Both states have values that have no value nil
*/
A value of 9 contains an integer value
var p1:int? = 9
No value
var p2:int? = Nil
Or
var p3:int?
//! Forced resolution of optional values if it is nil cannot force parsing of optional values
Get optional values to add!
Swift summarizes a