Lesson two learn some of the basic types of swift and flow control statements
After the Xcode environment configuration is complete, the first project is created, the first one raised is a question, wheremain is, in the Swift language, main is represented as a class, quite with a leading brother, A main class, the properties, methods, and objects of any class in theSwift language are put into the main class to implement.
First, the basic type
1. Basic
In the Swift language Let's declare a constant,var declares a variable type
columns such as:let L = 1;
var v = 2;
The v variable defined by var is the value that can be modified later, and the L constant defined by the Let is immutable.
2. String
The string is mutable, just as the variable declared by Var above defines. var v = 2;
A string is a value type that represents a string that can consist of shaping, floating-point, character, and so on.
3. Number types
Number types include: integer int, single-precision float, double -precision doubles.
4. Boolean Type (Boolean)
Boolean type:ture ,false.
5. Character type (character)
Character type: Charater, which is equivalent to the JAVA Char, two declarations of the same character type.
6. Ganso (tuple)
Ganso is the type of Swift language, it is different from other types, other types have similar types in other languages, this type of JAVA was born I have not touched.
Popular point: Thetuple represents a whole information, such as ID card, which has your name (string), Gender (boolean), ID card and so on information, That is, one can store multiple types of information and treat it as a whole.
The initial language of Swift involves