From: Peter Bailey Date: 2006-05-23T23:08:28+09:00 Subject: Re: How to "go to" in a RUBY script . . . Leslie Viljoen wrote: > On 5/18/06, DEBAUN, STEVE [AG-Contractor/2400] > wrote: >> To everyone else: >> I'll distract him, while y'all get a rope. > > hehe. I recently noticed that C# still has a goto, although it seems > that you can't have a label right at the end of a function since the > label must precede an actual statement. I found it to be useful in a > case where I was deep in nested loops, searching for a string and had > just found it, so I needed to jump out. It seemed so much clearer and > simpler to use the goto rather than have > > if (... & flag_variable) > > in every loop condition., even though I had to put silly nop > statements at the end of the functions. > > In Ruby I sometimes do similar things with Exceptions, since an > Exception a rather glorified goto-with-parameters. > > I think the great fear of having spaghetti code resulted in a bit of > an over-reaction: the universal condemnation of goto. Goto is still > sometimes simple and useful. > > L Wow. I guess, way back when, my referring to GOTO really sparked a conversation here. It's not that I still write DOS scripts. I have used it recently, though, in Windows cmd.exe scripts, which, no, are not DOS. This is juicy stuff. Thanks, everybody. Catch and throw, exceptions, . . ., all good stuff. -Peter -- Posted via http://www.ruby-forum.com/.