
front and back-end web development, Leeds, UK
Richard's Blog - Design, coding and life in Japan
Ruby Hash is not ordered
Submitted by Richard on Thu, 10/22/2009 - 09:48Just to let you know, I had a hash like below in a test
options_hash = {"把手タイプ"=>"バー把手(E)", "扉カラー"=>"ナディマスカット(NM)", "シンクの位置"=>"左シンクタイプ", "ガス種"=>"プロパンガス(LPG)"}I was trying to parse this into a string for options on a shopping cart, but I was wondering why the order screwed up until I read the Ruby docs, duh!
So I made it an array instead
options_hash = [["把手タイプ","バー把手(E)"], ["扉カラー","ナディマスカット(NM)"], ["シンクの位置","左シンクタイプ"], ["ガス種","プロパンガス(LPG)"]]
Tags:
Recent Blog Posts
- Testing controllers in Lithium 2nd Feb 12, 18:19
- Practical Internationalization in Lithium 31st Dec 11, 02:06
- Using OAuth in Lithium 30th Dec 11, 23:47
- How to add your own Tokens from CCK fields in Druapl 7 17th Jun 11, 04:49
- Weaving Lithium #li3 into a legacy PHP application incrementally 5th Oct 10, 11:54
Post new comment