On 28.5.2007, at 4.46, giles bowkett wrote:
Hi, I have a change I want to submit, just want to check that it's relevant first. Is scaffolding continuing as normal? When I see posts about getting rid of dynamic scaffolding, does that refer to scaffolding .erb templates, or to the scaffold controller method? The scaffolding templates all use <% for x in y %> instead of <% x.each do |y| %> Total subtle psychological difference, but with Rails having such incredible success, a little thing like that will encourage a lot of new Ruby programmers to use iterators instead of explicit iteration. For many programmers this is a big change:http://technotales.wordpress.com/2007/04/14/explicit-iteration- considered-harmful/When I started programming in Ruby, another programmer criticized my code. He was real subtle about it. Any time I wrote a for loop, he told me he'd never used one in Ruby. I was like, sure, that's great, have you ever used scaffolding? He was encouraging me in good habits, and scaffolding was my excuse for keeping up bad habits.
"for x in y" is basically just syntactic sugar on top of "each" in Ruby, it's not an explicit loop in the same sense that the following would be:
x = 0
while x < arr.size
# do something with arr[x]
x += 1
end
Like Mislav said, some consider "for x in y" nicer looking than
"y.each do |x|".
Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
