: 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