3 ms·
For the sake of argument, there's really nothing wrong with combining map/reduce with side-effects, especially for things like counters were the alternative of
by saiojd 5y ago
For the sake of argument, there's really nothing wrong with combining map/reduce with side-effects, especially for things like counters were the alternative of threading the variables everywhere can end up being much more complex very quickly.
- zdragnar 5y agoFor the sake of argument, use `forEach` if you want to introduce side effects. `map` and `reduce` are names with meaning, and passing impure functions to them is more confusing than passing some procedural function to `forEach` or using `for of`. It is something of a nit-picky argument to be sure, but it is a good mental habit to have. Edit: I think being strict with the semantic building blocks is a good mental habit, not necessarily making nit-picky arguments.
- the-smug-one 5y agoBeing disciplined is part of good engineering. To have clearly defined idioms is important, so I want to reinforce that this is not nit-picky. You can argue that anything is nit-picky, under the guise of subverting good engineering in exchange for getting to be lazy.