------art_115480_19263650.1167193701453
Content-Type: text/plain; charset=ISO-2022-JP; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Jeremy,

Thanks for the response.  That makes sense to try and use/leverage what
people are likely to already know, and a C-style while loop would definitely
be one of those things.  I was thinking more along the lines of someone
coming fresh to programming, where it might be more useful to teach them the
nice clean ways we have of doing things up front and to help them avoid
off-by-one errors and things like it.

Thanks,
Tyler Prete

On 12/25/06, Jeremy McAnally <jeremymcanally / gmail.com> wrote:
>
> Hey Tyler,
> While thats the most Rubyish way to do it, at that point in the text I
> hadn't covered those sorts of loops/iterators yet and thought that the
> while method would be more familiar to those reading.  I may change it
> in the next revision, but I'm not sure. :)
>
> --Jeremy
>
> On 12/22/06, Tyler Prete <psyonic / gmail.com> wrote:
> > 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  
> >   while (iter < myarray.length):
> >     yield(myarray[iter])
> >     iter + 
> >   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
> >
> >
>
>

------art_115480_19263650.1167193701453--