If you add a space after the + also, it’ll be fine (indeed, better).
But to be honest, I hate code that tries to do 5 bits of logic on one 100-character-long line, instead of just breaking into two more readable lines. [Edit: looks like that was fixed in the version at http://willbailey.name/conway/docs/conway.html]
Also, can’t your isAlive function look like:
isAlive: (row, col) -> @world[row]?[col]?.live@amirshim:
Yes, range comprehensions were recently optimized to remove direction-checking when possible. On CoffeeScript master ...
x for x in [-10..10]
... compiles into: var x;
for (x = -10; x <= 10; x++) {
x;
}
Even if the start/end values are variables, the check can be avoided by specifying the step as a number. It'll go out with the next release.
I personally like code like this:
but you have to be careful, since putting a space before the "+x" will cause some bad stuff to happen. Maybe I shouldn't drop so many parenthesis.@jashkenas can you fix [-10..10] (constant boundary) loops to not check for increasing/decreasing :) I can't think of an edge case that breaks it.