01.swift Foundation

Source: Internet
Author: User

Swift Chinese is a very exciting thing. I am particularly important for English is not so impressive. The overall view of the time did not spend too much. Although look completely forgot. But after all, swift2.0 is the trend, and open source. So mastering swift not only makes it easy to write any code that OC can achieve, but it can greatly save the amount and time of coding. Give people more time to analyze the business logic and the overall framework.

Thanks again for the collaborative compilation of a group of Chinese developers for the benefit of people! Attach git address

Https://github.com/numbbbbb/the-swift-programming-language-in-chinese

(1) Let modifier constants, only one decision at a time. The string, \ () can quickly become a string. And you can add: the way to declare the type

Let apples = 3

Let oranges = 5

Let applesummary = "I have \ (apples) GE apples"

Let fruitsummary = "I has \ (apples + oranges) ge fruits"

println (Applesummary)

println (Fruitsummary)

(2) var is a variable that can be determined multiple times

/**

* Dictionary arrays are Var

*/

var array = ["hehe", "Xixi", "Lala"]

ARRAY[1] = "Ooooooo"

println (Array)

var dict = [

"hehe": "en",

"Xixi": "Enen"

]

dict["hhhhh"] = "new"

dict["hehe"] = "Enenenenen"

println (Dict)

(3) Create an empty dictionary, array

Let Emptyarray = [String] ()

Let emptydict = [String:float] ()

(4) Cycle

var a = [10,13,312,32,2]

var b = 0

For C in a{

If C > 50{

B + = 5

}else{

B + = 3

}

}

(5)

(6) switch

(7) Type aliases

(8) Meta-group

(9) Optional type

Forced parsing of optional types:

(10) Optional bindings

(one) Nil

(12) Assert:

You can add an assertion when the program needs to be judged and is not able to run when it is true to continue. For example, the age must be greater than 0, and an assertion is triggered if less than 0. The program is not running.

01.swift Foundation

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.