
attractive, usable web applications
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
- Why you should use Rails 3 and not Django 5th Sep 10, 12:28
- Doctrine 2 and why you should use it! 29th Jul 10, 15:23
- How to localize your main blog listing page using Drupal 26th Jun 10, 11:46
- Creating Rails like template helpers in Django 24th Jun 10, 22:01
- Error: No module named messagesdjango.contrib.contenttypes 22nd Jun 10, 22:00
Post new comment