Skip to content

Instantly share code, notes, and snippets.

@vincentchu
Created June 27, 2011 22:04
Show Gist options
  • Save vincentchu/1049972 to your computer and use it in GitHub Desktop.
Save vincentchu/1049972 to your computer and use it in GitHub Desktop.
# For multi-line blocks, use do. E.g.:
users.each do |user|
user.name = "foo"
user.save
end
# For single-line blocks, use {}
users.each {|user| user.destroy }
# Even more trickery (equivalent to one above):
users.each(&:destroy)
# EXCEPTION: multi-line blocks, that are called by something else Example:
users.map { |user|
user.name
}.join("\n")
# This is equivalent, but looks strange
users.map do |user|
user.anem
end.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment