Last active
December 3, 2022 19:16
-
-
Save TsRebornz/8d40da03b2ffa8685869dd45d72b0c53 to your computer and use it in GitHub Desktop.
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 matrixFirstCellValue = \Matrix[0,0] | |
struct Matrix { | |
var data: [[Int]] | |
subscript(row: Int, column: Int) -> Int? { | |
return data[column][row] | |
} | |
} | |
let matrixFirstCellValue = \Matrix[0,0] | |
let matrix = Matrix(data: [[1,2,3], [4,5,6], [7,8,9]]) | |
let matrixElem = matrix[keyPath: matrixFirstCellValue] // -> 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment