in reply to When would you choose foreach instead of map?
When would I use map? When I want to make a copy. Otherwise, I'd let other considerations take precedence. I prefer not to use map in void context, then I use foreach — as a matter of style only, there's no real technical reason to dismiss map. I use map to calculate a function value, either in scalar (count of items) or list context.
|
|---|