Hi -- On Fri, 31 Jul 2009, David A. Black wrote: > On Fri, 31 Jul 2009, Rob Biedenharn wrote: > >> But David, should the behavior of: >> >> statement while condition >> >> be different from: >> >> begin statement end while condition >> >> which is what the issue boils down to. When the statement is enclosed in a >> block, it is evaluated once before the condition is checked. This is what >> I intended to show very explicitly in my response to Lloyd. > > I wasn't sure which issue was the focus (see my response to Lloyd > about the Pascal thing). I personally don't have any problem with the > above difference. I think they exist for different reasons: the > begin/end one specifically as a way of forcing at least one execution > of statement (as opposed to while conditions; statement; end), and the > one-line modifier form just as a convenience. > > I don't have an air-tight technical argument, though. (There probably > isn't one.) This discussion got me curious about something I remembered from days gone by: namely, that if you add a "rescue" to a begin/end/(while|until) construct, it ceased to do the one execution of the block. It's mainly of historical interest, since it was changed by Ruby 1.8.6. But it's just so much fun showing how ruby-versions.net works that I can't resist! :-) $ ruby160 -e 'begin; puts "hi"; rescue; end until true' $ ruby171 -e 'begin; puts "hi"; rescue; end until true' $ ruby186 -e 'begin; puts "hi"; rescue; end until true' hi David -- David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com Q: What's the best way to get a really solid knowledge of Ruby? A: Come to our Ruby training in Edison, New Jersey, September 14-17! Instructors: David A. Black and Erik Kastner More info and registration: http://rubyurl.com/vmzN