Created
March 25, 2015 03:01
-
-
Save samuraijane/b201e2ee704f3ec7afb5 to your computer and use it in GitHub Desktop.
Each is considered better form than a for loop. Although they achieve the same results, the variable in the for loop is retained after it executes (which can make debugging more difficult) while the variable in each only lives inside the block.
This file contains hidden or 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 item in ids | |
puts item | |
end | |
%> | |
<% | |
ids.each do |item| | |
puts item | |
end | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment