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. Advertisements

  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. Advertisements

  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. Advertisements

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. Neo Geshel
    Replies:
    2
    Views:
    4,421
    Versteijn
    Aug 18, 2004
  2. William
    Replies:
    2
    Views:
    2,133
    Kevin Spencer
    Jun 1, 2005
  3. Replies:
    2
    Views:
    492
  4. Patrick Stadelmann

    Quit menu notification with SWT on Mac OS X ?

    Patrick Stadelmann, May 16, 2008, in forum: Java
    Replies:
    7
    Views:
    3,189
    Patrick Stadelmann
    May 19, 2008
  5. Jimmy
    Replies:
    3
    Views:
    496
    J. J. Farrell
    Sep 9, 2011
  6. Jimmy
    Replies:
    13
    Views:
    897
    Peter Nilsson
    Sep 21, 2011
  7. Karen Sundquist
    Replies:
    1
    Views:
    290
    Saurabh Nandu
    Dec 1, 2003
  8. Nagesh
    Replies:
    1
    Views:
    199
    Bob Barrows
    Jul 28, 2003
Loading...