On Sat, Feb 16, 2013 at 2:03 PM, Stu P. D'naim <[email protected]> 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
<[email protected]> 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


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- 
[email protected] | 
https://groups.google.com/d/forum/ruby-talk-google?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to