how to make "quit" at the end of "menu"

Discussion in 'Ruby' started by Gpy Good, May 5, 2007.

  1. Gpy Good

    Gpy Good Guest

    I create a ruby program that need a menu from database:
    menu={
    "open file"=>"file.html",
    "save file"=>"save_file.html",
    "quit"=>"quit.rb"
    }

    puts menu.inspect

    =>
    {"open file"=>"file.html", "quit"=>"quit.rb", "save
    file"=>"save_file.html"}

    BUT,i hope that as I create menu's ordered
    =>
    {"open file"=>"file.html", "save
    file"=>"save_file.html","quit"=>"quit.rb"}

    --
    Posted via http://www.ruby-forum.com/.
     
    Gpy Good, May 5, 2007
    #1
    1. Advertising

  2. Gpy Good

    Gpy Good Guest

    or,Is there have a hash method like to_map ?

    puts menu.to_map.inspect
    =>
    {"open file"=>"file.html", "save
    file"=>"save_file.html","quit"=>"quit.rb"}


    --
    Posted via http://www.ruby-forum.com/.
     
    Gpy Good, May 5, 2007
    #2
    1. Advertising

  3. On Sun, May 06, 2007 at 07:32:14AM +0900, Gpy Good wrote:
    > I create a ruby program that need a menu from database:
    > menu={
    > "open file"=>"file.html",
    > "save file"=>"save_file.html",
    > "quit"=>"quit.rb"
    > }
    >
    > puts menu.inspect
    >
    > =>
    > {"open file"=>"file.html", "quit"=>"quit.rb", "save
    > file"=>"save_file.html"}
    >
    > BUT,i hope that as I create menu's ordered
    > =>
    > {"open file"=>"file.html", "save
    > file"=>"save_file.html","quit"=>"quit.rb"}


    If ordering is important, don't use a hash.

    menu = [
    ['open file','file.html'],
    ['save file','save_file.html'],
    ['quit','quit.rb'],
    ]
     
    Brian Candler, May 6, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M. Duijkers
    Replies:
    2
    Views:
    483
    Joe Smith
    Dec 12, 2004
  2. Craig

    Postback quit working

    Craig, Sep 27, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    674
    Kikoz
    Sep 27, 2004
  3. GD
    Replies:
    2
    Views:
    371
  4. Replies:
    2
    Views:
    359
  5. Patrick Stadelmann

    Quit menu notification with SWT on Mac OS X ?

    Patrick Stadelmann, May 16, 2008, in forum: Java
    Replies:
    7
    Views:
    2,875
    Patrick Stadelmann
    May 19, 2008
Loading...

Share This Page