Swift Basic Writing specification

Source: Internet
Author: User

Create a swift project:

Come to the main function, what? Can't find the main function like OC?

Stop the nonsense, on the code, I will analyze:

//fundation Basic PackageImport Foundation//Do not execute main function, execution order from top to bottom//Execute this prinr function//Lua Pathon language does not require a semicolonPrint ("Hello, world!.")//define variable int A; variable definitions start with Var and declare a variable//MyVar is a variable name, where the name of the variable needs some initializationvar MyVar =0MyVar= -  //variable name can be assigned again//\ () indicates that the contents of the (inside) can be calculatedPrint"my var is: \ (myVar)")//String (MyVar) is the object that is converted to a string typePrint"my var2 is"+String (MyVar))//Define a variable: represents the type Int denotes the declaration typevar myvar3:int = $;p rint ("my var3 is \ (MYVAR3)") var myvar4:double=3.1415926;p rint ("my VAR4 is\ (MYVAR4)")//let means to set an immutable variable, change the errorLet MYVAR5 = -;//MYVAR5 = +;Print"my var5 is \ (MYVAR5)") var myVar6= -; var myVar7= -; var myVar8= MyVar6 +Myvar7;print ("myVar8 is \ (MYVAR8)")//Country is a variable namevar name ="XZR"Print ("name is \ (first name)")

Yes, I did not execute the main function, it came to our Main.swift file after it was executed sequentially from top to bottom, I added a note, understand?

Well, command + R, you can see it!!!

An epiphany! As for writing norms to practice more practice to practice more, important things to say three times three times three times.

Summary: Later perfect ...

Swift Basic Writing specification

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.