From: "T. Onoma" Date: 2004-09-06T13:51:15+09:00 Subject: Re: Hashes and ordering On Saturday 04 September 2004 07:39 pm, Aredridel wrote: > Oooh, I like that! :-) Well, how bout a taste then! class Association < Array def initialize( key, value ) self.replace [ key, value ] end def key self[0] end def value self[1] end end module Kernel # note this clashes with Bignum, Fixnum and Date :( def >>( associate ) Association.new( self, associate ) end end # of course we need to teach array about working with associations class Array alias_method('get','[]') def [](i) r = self.get(i) return r.value if r.is_a? Association return r end alias_method('gat','at') def at(i) r = self.gat(i) return r.value if r.is_a? Association return r end end if $0 == __FILE__ omap = [ :a >> 1, :b >> 2 ] p omap[0] omap.each { |a| p a } puts "---" omap.each { |k,v| p k,v } end Just threw this together, but looks like it works pretty well already. When I have more time I'll finish her up, or if you'd like then go for it. Just let me know so I can add it my lib too! Thanx.