5 ms·
The same argument was made recently about the reduce function: it's a known pattern for some and a hard to understand trick for others.
by galoisgirl 6y ago
The same argument was made recently about the reduce function: it's a known pattern for some and a hard to understand trick for others.
- jraph 6y agoYes, and you get used to reduce. map, filter and reduce were hard for me to follow… until I used them two or three times and now I understand them easily and they naturally come to my mind when I need to solve a problem which they can help solving. They are good tools (especially in codebases shared with people who are allergic to loop statements!)
- doubletgl 6y agoAgreed for map, filter etc. but reduce is the exception. There has been a fad of overusing it, until that article popped up which called it out.
- jraph 6y agoI "got" reduce not long ago. It's occasionally handy, and it makes sense, but sure, it should not be overused. It is the most complicated between the three. A good old loop in code bases that are not afraid of them are totally fine and probably clearer in many cases.