Skip to content

Instantly share code, notes, and snippets.

@TsRebornz
Last active December 3, 2022 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TsRebornz/8d40da03b2ffa8685869dd45d72b0c53 to your computer and use it in GitHub Desktop.
Save TsRebornz/8d40da03b2ffa8685869dd45d72b0c53 to your computer and use it in GitHub Desktop.
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