3 ms·
> For example, say you've got a function that ends with a for loop. CoffeeScript will actually convert that into an array allocation and return the result of th
by lowboy 13y ago
> For example, say you've got a function that ends with a for loop. CoffeeScript will actually convert that into an array allocation and return the result of the array.
Simple, just return anything else, or nothing at all:
myFn = () ->
for el of array
# loop body
return
> CoffeeScript also can't make up its mind about whether parens are necessary.
Well, in some cases they're optional, but it's predictable and hardly "can't make up its mind". I've never run into a problem with this. Implicit parens wrap to the end of a line or block expression, and it feels pretty natural:
f g h obj -> f(g(h(obj)))
f g, h, obj -> f(g, h, obj)
f().g().h obj -> f().g().h(obj)
Every time there's a space, you're introducing a new fn call. Every time there's a comma, it's adding a parameter to the fn call. So yeah, you will have to use parens for any chaining style (a la jQ and many others), and to disambiguate complex nested fn calls, but that's expected.
I prefer to think of parens as sometimes optional.