I built a mainmenu with the individual points leading to submenus. I want to let the user jump from a submenu to the mainmenu. In BASIC, this is possible with GOTO, in other languages I would load a module and put a new link. What do I do in Ruby? I am looking for an equivalent to GOTO.
Asked
Active
Viewed 51 times
0
-
1GOTO doesn't exist in modern languages. I suppose that you should show us what you've got so far, and we'll be able to help you from there. – Makoto Sep 05 '15 at 18:35
-
3I'm guessing each of your menus consists of some code that displays a menu and asks the user for a choice? In that case you could define a function for each menu. That way the program will automatically jump back. – Tesseract Sep 05 '15 at 18:35
-
1Ruby doesn't come with a `GOTO` equivalent by default. While it's possible to [add `GOTO` through a Gem (a Ruby library)](https://rubygems.org/gems/goto) or [by recompiling MRI with not-so-serious compile options](http://patshaughnessy.net/2012/2/29/the-joke-is-on-us-how-ruby-1-9-supports-the-goto-statement), believe me that **this. Is. Not. What. You. Want.** Instead, make yourself familiar with [structured programming](https://en.wikipedia.org/wiki/Structured_programming). If you feel you need `GOTO`, [you're doing it wrong](https://www.xkcd.com/292/). – das-g Sep 05 '15 at 18:49
-
thanks das-g and @SpiderPig, that was useful! – user234 Sep 05 '15 at 19:05
-
Only old people truly understand the evil that was embodied in `GOTO`. – Cary Swoveland Sep 05 '15 at 20:09
-
It doesn't take being old to understand it, it just takes reading the arguments against it or using a language that supports it long enough to have encountered spaghetti code. – the Tin Man Sep 05 '15 at 22:09