Skip to content

Instantly share code, notes, and snippets.

@BeauNouvelle
Created August 6, 2018 02:14
Show Gist options
  • Save BeauNouvelle/ffb50074c8e76aff1aba6b9dd49ddb81 to your computer and use it in GitHub Desktop.
Save BeauNouvelle/ffb50074c8e76aff1aba6b9dd49ddb81 to your computer and use it in GitHub Desktop.
let firstCell = Cell(x: 10, y: 10, state: .dead)
let secondCell = Cell(x: 11, y: 10, state: .dead)
print(firstCell.isNeighbor(to: secondCell))
// true - Same row, adjacent column.
let firstCell = Cell(x: 10, y: 10, state: .dead)
let secondCell = Cell(x: 20, y: 10, state: .dead)
print(firstCell.isNeighbor(to: secondCell))
// false - Same row, vastly different column.
let firstCell = Cell(x: 10, y: 10, state: .dead)
let secondCell = Cell(x: 10, y: 10, state: .dead)
print(firstCell.isNeighbor(to: secondCell))
// false - Same row, same column. They're identical cells!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment