From: "Ara.T.Howard" Date: 2004-06-30T11:22:54+09:00 Subject: Re: [ANN] arrayfields-3.0.0 On Wed, 30 Jun 2004 nobu.nokada@softhome.net wrote: > Hi, > > At Wed, 30 Jun 2004 05:02:58 +0900, > Ara.T.Howard wrote in [ruby-talk:104864]: >> http://raa.ruby-lang.org/project/arrayfields/ >> http://www.codeforpeople.com/lib/ruby/arrayfields/ > > $ ruby-1.8 -r arrayfields.rb -e '[][:x]' > -e:1:in `[]': Symbol as array index (TypeError) > from -e:1 > $ grep VERSION arrayfields.rb > VERSION = '3.1.0' > > `and' and `or' operators have same precedence. the instance only is extended, and only then after instance.fields= has been called. eg. ~ > ruby -r arrayfields-3.0.0 -e 'a = [42]; a.fields = [:answer]; p a[:answer]' 42 ~ > ruby -r arrayfields-3.1.0 -e 'a = [42]; a.fields = [:answer]; p a[:answer]' 42 so, in the normal case only the method Array#fields= is added when you require 'arrayfields' i didn't want to polute the namespace any more than needed. > BTW, you couldn't use Struct? > > tuples = > fields = Struct.new(nil, res.fields) > > tuples = res.collect {|tuple| fields.new(*tuple)} i suppose i could... but there the would have a lot of object create on large result sets no? regards. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================