users.select(&:meets_some_critera?).each(&:update!)
You could totally do that in a for each loop if you wanted. But it isn't really composable. While this works for the basic update... for user in users do
user.update! if user.meets_criteria?
end
... what if you wanted to then sum up the new account balances? In the first example, you'd just chain on a couple more enumerable methods: users.select(&:meets_some_critera?).each(&:update!)
.map(&:account_balance).inject(&:+)
With the for each construct you'd have to pass in an accumulator variable and keep track of whether to sum or not. While you certainly can do it in a for each construct, I'd argue that you'd be missing out on what makes ruby, ruby. And getting beginners in that more functional(ish) frame of mind sooner rather than later is a very good thing.--edited a few times for formatting/clarity