The initial language of Swift involves

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.