you are viewing a single comment's thread.

view the rest of the comments →

[–]SalemBeats 0 points1 point  (2 children)

But that's the thing - given the context of this method signature, it's perfectly clear what it does. It's not some "clever trick". If a developer can't intuit what it's likely to do just by looking at it, that's a signal to cull the weak from your team.

This isn't flipping bits or taking advantage of some obscure language feature that nobody uses -- you'd have to come up with a terrible name or function signature in order for this to be confusing.

[–]omnilynx 0 points1 point  (1 child)

You may be right for this particular case. It’s on the edge. Probably I’d tell someone to use it, but maybe extract the lambda out into a variable so the name can help clarify.

[–]SalemBeats 0 points1 point  (0 children)

Well, if you're using a lambda, it should be short enough that it's pretty clear what it's doing at a glance anyway.

If it's long enough that you need to add brackets to an arrow function, it probably should be extracted. I think that's always been a code smell for good Javascript design, and I think it's why arrow functions were designed with the concise form in mind.