Iterate without an explicit block idiom
In my code, I have an array of ActiveRecord::Base objects, and to save
them, for example, I would do something like this:
obj_list = [ar_obj1, ar_obj2, ar_obj3]
obj_list.each { |obj| obj.save! }
It would perhaps be nice and DRY to say instead:
obj_list.each.save!
However, I cannot see how to do this.
No comments:
Post a Comment