ruby on rails - Enumerable select to set attribute and return object -


i need iterate on array, set attribute, , return modified objects.

obviously, map can used so:

items.map |item|    item.foo = bar    item end 

but seems bulky such simple operation.

using select more simple.

items.select { |item| item.foo = bar } 

however, i've used select test condition. in scenario, condition not being tested during iteration, still returning true upon setting attribute.

is acceptable way use select or hack?


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Why am I getting Internal .NET Framework Data Provider error 1025 when passing Method to where? -

linux - phpmyadmin, neginx error.log - Check group www-data has read access and open_basedir -