Forum: Ruby how to make "quit" at the end of "menu"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ba608f20b6707017d9812b9b3f1406e3?d=identicon&s=25 gpy good (gpygood)
on 2007-05-06 00:32
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"}
Ba608f20b6707017d9812b9b3f1406e3?d=identicon&s=25 gpy good (gpygood)
on 2007-05-06 00:37
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"}
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (Guest)
on 2007-05-06 09:25
(Received via mailing list)
On Sun, May 06, 2007 at 07:32:14AM +0900, Gpy Good wrote:
> {"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'],
]
This topic is locked and can not be replied to.