4 ms·
Close, but I checked it and the value of `i` won't bind to the function. You also have to use `...` (exclusive range) instead of `..` to prevent an off-by-one e
by rmrfrmrf 12y ago
Close, but I checked it and the value of `i` won't bind to the function. You also have to use `...` (exclusive range) instead of `..` to prevent an off-by-one error.
Here's one way:
foo = (n) -> ((a) -> a).bind(null, i) for i in [0...n]
Here's a more esoteric/bad style (but cute) way:
foo = (n) -> (-> +@).bind i for i in [0...n]
- alxndr 12y agoI've been preferring explicit `map()`s in my CoffeeScript for exactly that reason.