SWIFT-25-Control transfer and two-dimensional arrays

Source: Internet
Author: User

: Playground-noun:a place where people can playimport uikit//fallthrough//Fallthrough will continue the next case//after the current case is executed if the next    If a variable is declared in a case, you cannot use fallthroughvar coordinate = (1, 0) switch coordinate {case (0, 0): Print ("It's at origin!")    Fallthroughcase (_, 0): Print ("(\ (coordinate.0), 0) is on the x-axis.")    Fallthroughcase (0, _): Print ("(0, \ (coordinate.1)) is on the y-axis.") Fallthroughcase ( -2...2, 0...2): print ("The coordinate is (\ (coordinate.0), \ (coordinate.1))") Default:print (\ (COO rdinate.0), \ (COORDINATE.1)) is just an ordinary coordinate ")}//breakfor var i = 0; I < 10;            i++ {print (i) for var j = 0; J <; + J {print (j) if i + j = = Ten {print (i + j) Break//Jump out of the loop body where the break is located}}}//continuevar str = "ASKDJFSKLDJFDIFJHGET,N,MCNMVXCVAWPERIUZXNCV,."            var num = 0;for string in str.characters {switch string {case ', ', '. ': num++ default:    Continue }}//Initializes a two-dimensional array of VAR board = array<array<int>> () for I in 0..<10 {//Count: The number of elements after the array is initialized Repeatedvalue: The value of the element of the array Board.ap Pend (Array (Count:10, repeatedvalue:0))}let randx = Int (arc4random ()%10) Let randy = Int (arc4random ()%10) board[randx][ Randy] = 1board//Mainloop is used to mark a loop, and with a tag, break can jump out of a specified loop directly. Eg:var i = 0, j = 0mainfor:for i = 0; I < 10;        i++ {///mainfor This tag is customizable for j = 0; J < + J + + {if board[i][j] = = 1 {break mainfor }}}print ("Board[\ (i)][\ (j)] = 1")

  

SWIFT-25-Control transfer and two-dimensional arrays

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.