Swift Basic Tutorials (Geek College) Notes

Source: Internet
Author: User

Http://www.swiftv.cn/course/hw4sysi7 This course is short and adds up to one hours, suitable as a quick learn. 0. Environment Xcode-workspace-project-command Line OS X application 1. Variable type var variable let constant println () output requires no semicolon (c-like) and indentation (Python-like) but The branch manually indicates the type var x:int = 3 Note = Both sides should have a space (1) string connection str=str+ "\ (i) People" Here i is an integer variable (2) arrayvar x=["Hi", 1,0.2] empty array is [], empty   string array is [string] () array can println (3) dictvar x=["HI": 2, "a": 3] Key and value by: Separate, pair is also separated by commas, note that the type of pair do not need to be the same x["s"]=f Same as assignment 2. loop control for I in 1 ... 100{}while i<arr.count{}for (Key,value) in dict{} if i%2==0{} optional variable var y:string? = "Tom" Y=nil If Let name=y{} 3. function
Func cal (A:int,b:int)-(int,int) {    return(a+b,a-b)}let (m,n)=cal (3, 1 ) println (m)
var t=sayhi the function as the variable t ("Jack") 4. Class
1 Import Foundation2 3 classhi{4 5 func Sayhi () {6 7println"Hi, Jack .")8 9     }Ten  One } A  - varx=hi () -  the X.sayhi () -  - classhello:hi{ -  +     var_name:string -  + Init (name:string) { A  atSelf._name=name -  -     } -  -     Overridefunc Sayhi () { -  inprintln"Hello \ (self._name)") -  to     } +  - } the  * varY=hello (Name:"Mike") $ Panax NotoginsengY.sayhi ()

Swift Basic Tutorials (Geek College) Notes

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.