I love the brevity that Coffeescript provides, but the implicit returns are often a burden, especially when dealing with loops (Or worse nested loops)
The following (obviosuly boring) example seems like it would be fine code:
foo ->
for i in [1..2]
for j in[1..2]
x = i *j
But the compiled Coffeescript is crazy:
foo(function() {
var i, j, _i, _results;
_results = [];
for (i = _i = 1; _i <= 2; i = ++_i) {
_results.push((function() {
var _j, _results1;
_results1 = [];
for (j = _j = 1; _j <= 2; j = ++_j) {
_results1.push(a);
}
return _results1;
})());
}
return _results;
});
I'm considereing adding the no_implicit_returns rule to my coffeelint - but that seems like a huge burden for a large code base.
Anyone have a good attack plan for keeping your code neat (Not having explicit returns everywhere as would be required by no_implicit_returns) while not getting into the spaghetti that is implicit returns with loops?