Skip to content

Instantly share code, notes, and snippets.

@stevenbristol
Created December 16, 2008 19:28
Show Gist options
  • Save stevenbristol/36738 to your computer and use it in GitHub Desktop.
Save stevenbristol/36738 to your computer and use it in GitHub Desktop.
class Object
def save
rand > 0.5
end
end
array_of_unsaved_active_record_objects = []
1.upto(10) { |i| array_of_unsaved_active_record_objects << i}
all_saved = true
array_of_unsaved_active_record_objects.each do |ar|
x = ar.save
puts "#{ar} saved?: #{x}"
all_saved &&= x
end
puts "They all saved: #{all_saved}"
1 saved?: true
2 saved?: false
3 saved?: false
4 saved?: true
5 saved?: false
6 saved?: false
7 saved?: false
8 saved?: false
9 saved?: true
10 saved?: false
They all saved: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment