Created
March 25, 2015 00:36
-
-
Save samuraijane/d5450e1b1d14d5ff5aa8 to your computer and use it in GitHub Desktop.
An `each` statement is basically a loop in which you can define a variable. However, you can only use that variable within the statement itself. If you need that variable outside of the statement, use `do`.
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
#Each statements do not allow their variables to be used outside of the statement. | |
<%= friends.each{|friend| friend['children']} %> | |
#To do this use `do`. | |
<% friends.each do | |
|friend| @uno = friend['name'] | |
end %> | |
<%= "#{@uno}" %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment