Created
July 6, 2016 07:03
-
-
Save mitulmanish/09c605bcbf673b50a1bb8dec8d68e658 to your computer and use it in GitHub Desktop.
Iterating over 2D array in Swift(with indices)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let twoDimArr: [[Int]] = [[0, 0, 1], [1, 0, 1]] | |
for (i,row) in twoDimArr.enumerate() { | |
for (j, cell) in row.enumerate() { | |
print("m[\(i),\(j)] = \(cell)") | |
print("**************") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Swift 3
for (i,row) in twoDimArr.enumerated() {
for (j, cell) in row.enumerated() {
print("m[(i),(j)] = (cell)")
print("**************")
}
}