Ruby and some hacking

Richard Dale has been nice enough to try and explain the use of braces in Ruby.

I think I see what he means. From what I’ve been reading, you can associate blocks of code with different functions using the brace notation, which is simply a very nifty feature. It is how Ruby handles iterators, for instance, and it is possible to code many constructs using these.

What I have yet to do, however, is find a way to get braces to work with if, while, or other flow-control type statements. For example, the program yes implemented in Ruby:

<b>while</b> <b>true</b><br />     <b>print</b> <font color="blue">"y</font><font color="purple">\n</font><font color="blue">"</font><br /> <b>end</b>

I can’t get this program to work using a closing brace for the end, or even adding an opening brace manually and then using a closing brace. I think this is because the while statement seems to imply a begin (as does the def statement, for example). I mean, it’s not like it’d kill me to learn to type end again, it’s just that it means Ruby is fighting for mindshare in my head not with Python and C++, but with bash and high school Pascal. ;-)