attractive, usable web applications


Richard's Blog - Design, coding and life in Japan

Richard

Ruby Hash is not ordered

Just 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:

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Recent Blog Posts