Created
June 27, 2011 22:04
-
-
Save vincentchu/1049972 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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