From: tamouse mailing lists Date: 2013-02-16T23:58:00+09:00 Subject: Re: [from BASIC to Ruby] so, what's the proper way to replace funcionality of GOTO ? On Sat, Feb 16, 2013 at 8:20 AM, Robert Klemme wrote: > On Sat, Feb 16, 2013 at 2:03 PM, Stu P. D'naim wrote: >> hash inside hash menus, interesting, same as Robert Klemme's example ... > > There is one difference: I created a class while the other example > uses nested Hashes. Frankly, since with Ruby it is so easy to create > classes, I do not understand why people go about to suggest creating > nested structures of Hash and Array combinations. Look at this > example: > > On Sat, Feb 16, 2013 at 8:30 AM, tamouse mailing lists > wrote: >> @commands = { >> '1' => { >> :menu => "Thing 1", >> :action => lambda {thing1}}, >> '2' => { >> :menu => "Thing 2", >> :action => lambda {thing2}}, >> '0' => { >> :menu => "Quit", >> :action => lambda { :done }} >> >> } > > It shows quite obviously that there are "things" which always have a > "menu" (or rather a name) and an "action". Why then not just create a > class for that? > > Thing = Struct.new :menu, :action > > etc. > >> thank you all guys, now I have more than enough ideas how to start my >> script > > Good! > > Kind regards > > robert All very true. My initial thought was to refrain from jumping directly Classes, but it's probably just as well.