Possible Duplicate:
What is “for” in Ruby
Hey. My question is if these loops are the same when I iterate through an Array. Thx for your time!
<% for track in @tracks %>
or
<% @tracks.each do |track| %>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They are different (although it may not matter for your purposes).
fordoesn’t create a new scope:.eachcreates a new scope for the block: