Re:Elevator Saga – An elevator programming game
by SeoxyS on Friday January 23, 2015 @03:29AM
(#8933918)
Responding to GP; I think it's a tiny bit clearer with `== true`, but I don't feel particularly strongly about it. I wrote this code without caring too much about style and cleanliness.
However, I don't agree that the shortest code is always the cleanest. In JS for example, I've found that wrapping every conditional body in braces even if it's a single statement helps avoid bugs and clear out ambiguity.
However, I don't agree that the shortest code is always the cleanest. In JS for example, I've found that wrapping every conditional body in braces even if it's a single statement helps avoid bugs and clear out ambiguity.
Also, this code:
is not equivalent to because foo() could return something that isn't boolean. The correct short version would be: It's far less obvious what is going on here. That said, I'd probably go with: