3 ms·
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,
by AshleysBrain 11y 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.
- andrewstuart2 11y agoWell, 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; }
- ajanuary 11y agoMore 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.
- danbruc 11y agoJust 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.)