Hacker News new | ask | show | jobs
by AshleysBrain 4012 days ago
Who on earth would really write that? Surely you'd use the optional braces to make it clearer:

    a => { return b <= 7; }
Sure you can write it without that, but only if you want to write willfully unclear code to annoy people, like writing an entire function body on one line. Just because you can do that doesn't mean that functions are inherently unclear.
3 comments

More who on earth would really write a function that took a named argument, ignored it, and compared a value in the outer scope.

All of the examples that look confusing are artificially simple and doing things you wouldn't normally try to do.

Well, anybody who wants to use lambdas I'd imagine.

If you're going to write it out, you might as well just add the `function` keyword for clarity because you're not saving a ton of keystrokes.

    function(a) { return b <= 7; }
Just make it a => (a <= 7), that is perfectly fine for me. (I replaced the b with an a, otherwise it looks pretty pointless or maybe a strange closure hack.)