Graham,
As a newbie I'm confused about the Case construct. All
the documentation I've found states "case operates by
comparing the target with EACH of the expressions after
the When keyword"
The documentation should continue with "performing (expression ===
target), until the comparison returns true"
So my underlying question is:- what's the fastest Ruby
for checking which of the 8 possible adjacent cells on
a board (2D array) are still "on the board"
This is a very ambiguous question, but I think the answer to "what's
the fastest" is going to be testing each of the eight cells
individually. For example:
cells_left = [
cell[x - 1][y - 1],
cell[x ][y - 1],
cell[x + 1][y - 1],
cell[x - 1][y ],
cell[x + 1][y ],
cell[x - 1][y + ],
cell[x ][y + 1],
cell[x + 1][y + 1],
].compact
I hope this helps.
- Warren Brown