A swift tour

Source: Internet
Author: User

First, let's talk a little bit about the swift language. It is very easy for a person who has been writing JavaScript and Java code all the year round. As someone said, everyone has weaknesses and advantages. So far, I have only a preliminary understanding of this language and these two words have spread. Maybe, this is the case for weak languages.

I. Basic Knowledge

1. Basic Type

Integer: int

Float, double

Character Type: String

Boolean: bool

Set Type: array, Dictionary

PS: the first letter of the basic type must be capitalized, and the basic type cannot be directly defined (for example, int A = 10 as in Java; it should be var A: Int = 10 ;)

 
VaR AAA: Int = 100; var BBB: bool = true; var CCC: Double = 233.0; var DDD: Float = 333.4; var EEE: String = "33333"; let fff: int = 2000;

2. Console print statement: println () and print ()

Anyone who has learned C or C ++ knows this and prints logs. The usage is similar, but the difference is that println ("A: % d", a); is not allowed, but println ("A: \ ()");

3. latency statement: Sleep (1); // latency 1 second 

4. Clear screen statement: System ("clear screen"); // The console cannot appear

5. constants and variables:Constants are modified with let, and variables are modified with var..

6. semicolon:If only one line of code can be omitted and compiled, this semicolon can be omitted.

5. Question Mark and exclamation point :? Is to identify the variable as an optional variable or can be empty ,! Is to get the non-null value of the optional variable ,! It can also be used to identify variables as optional variables.

 

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.