3 ms·
Interesting, I use `map` all the time and `for` rarely. I'm not necessarily disagreeing with you as I see this as more of a style preference. The map approach
by freedomben 3y ago
Interesting, I use `map` all the time and `for` rarely. I'm not necessarily disagreeing with you as I see this as more of a style preference.
The map approach feels a lot more functional to me and is easy to chain. The `for` method feels a bit awkward. But that said I much prefer Ruby to Python. If I had the opposite preference, I'd probably like the `for` in Elixir more.
- square_usual 3y agoI agree with you: I prefer map and reduce unless I specifically need a comprehension because of multiple input collections. IMO for with many conditions etc. becomes too hard to understand, and you have to keep too many things in mind vs. a filter |> map. Regardless, I don't mind its presence, and it definitely has come in handy at times. Yet another reason to enjoy Elixir's approach to language design!
- bluesnowmonkey 3y agoI also use ‘for’ rarely. It silently ignore list elements that don’t match, whereas ‘map’ or ‘each’ blow up. Generally I prefer things to blow up rather than fail silently.