From: Joel VanderWerf Date: 2004-06-30T05:49:25+09:00 Subject: Re: [ANN] arrayfields-3.0.0 Ara.T.Howard wrote: > URLS: > > http://raa.ruby-lang.org/project/arrayfields/ > http://www.codeforpeople.com/lib/ruby/arrayfields/ > > SYNOPSIS > > allow keyword access to arrays: > > require 'arrayfields' > > fields = 'name', 'age' > row = [ 'bob', 30 ] > > row.fields = fields > > row[ 'name' ] #=> 'bob' > row.indices 'name', 'age' #=> [ 'bob', 30 ] Hm, sorta like something I've been using: --- module AccessibleIndex def index_accessor(h) h.each do |sym, idx| define_method sym do self[idx] end define_method "#{sym}=" do |val| self[idx] = val end end end end a = [0,1,2,3,4,5] class << a extend AccessibleIndex index_accessor :x => 3 end a.x = "three" p a # ==> [0, 1, 2, "three", 4, 5] --- But this approach doesn't help with values_at and the like.