The main reason to use a comprehension, is its increased flexibility.
When this flexibility is not necessary, using map/filter/reduce etc... is more idiomatic.
One thing that for-comprehensions can not do, is be pipelined, so in pipelines, the other functions are more frequently used. If you want to perform a slightly more complex manipulation of your data, though, it is good form to extract it to its own (private) function, in which case you can use whatever you want in its internals, of course.
Three things that only for-comprehensions provide are:
- Iterating over multiple collections at once. (all combinations of elements are then iterated over)
- In one go store the result of the comprehension in another thing implementing the Collectable protocol. (The Enum functions are all built on top of
reduce and therefore always build an intermediate list representation.)
- Have boolean properties to exclude certain fields from the thing you are constructing. With the Enum functions, you usually need to use multiple steps after one-another (e.g. fist filter, then map) to do this.