From: Tyler Prete Date: 2006-12-23T07:41:59+09:00 Subject: Re: Merry (slightly early) Christmas! Mr. Neighborly's Humble Little Ruby Book is free! ------=_Part_76305_27370488.1166827315418 Content-Type: text/plain; charset=ISO-2022-JP; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline This book is really great! I'm familiar with most of the material already, but I'm enjoying reading through it all the same. One question I have (a question of preference more than correctness) is in your example dealing with blocks and yield, why do you choose to use while with an interator: def myeach(myarray) iter = 0 while (iter < myarray.length): yield(myarray[iter]) iter += 1 end end testarray = [1,2,3,4,5] myeach(testarray) {|item| print "#{item}:"} → 1:2:3:4:5: Rather than using what seems (to me at least) the more Ruby way: def myeach(myarray) for elem in myarray yield elem end end That way you're not using an extra variable or having to worry about array length. A funny way to write it would be using blocks: def myeach(myarray) myarray.each { |elem| yield(elem) } end but I think that way basically defeats the purpose of your example ;) Anyway, I'm just interested in your thoughts about this. You most likely have your reasons and they probably make sense; after all, you're the one out there writing books :) Thanks and keep up the good work, Tyler Prete ------=_Part_76305_27370488.1166827315418--