by yakshaving_jgt · 4y ago · 0 comments
Is it bad to use map?
So if you're using map sensibly, no there's nothing wrong. But I don't like the dogma I read a lot which is "use map always" because it leads to inexperience developers using it in the wrong circumstances.
> Is it bad to use map?
No.
flatMap takes care of a lot of that
Of course if it were assumed they never need anything but the higher level methods: map, reduce, some, every etc. - then they would probably use some or every if they wanted to break.
I suppose filter could maybe be hacked to do it in some cases dependent on implementation, if the implementation determined that it was impossible to ever return true for any of the items remaining in an array that implementation might effectively break the array processing however every way I can think of doing that would be artificial, horrible, and probably full of side effects.
No it doesn’t.
You actually don't need `map`, you can easily implement that using `reduce` too ;)
There is utility in communicating whether you're working with a catamorphism vs a homomorphism. Code is written for humans, after all.