From: Jonathan Leighton Date: 2006-01-10T02:24:54+09:00 Subject: Re: Passing a hash of args On Mon, 2006-01-09 at 10:26 +0900, dblack@wobblini.net wrote: > > class Time > > UNITS = [ :year, :month, :day, :hour, :min, :sec, :usec ] > > > > def to_precision(unit) > > args = [] > > 0.upto(UNITS.index(unit)) { |unit| args << > > method(UNITS[unit]).call } > > Time.local(*args) > > end > > end > > > > Is that a sensible way to do it? > > I would do: > > send(UNITS[unit]) > > in preference to the method/call thing. Maybe: > > args = (0..UNITS.index(unit)).map { |unit| send(UNITS[unit]) } Awesome, thanks. I did feel the method/call bit was slightly ugly. Cheers -- Jonathan Leighton http://turnipspatch.com/ | http://jonathanleighton.com/ | http://digital-proof.org/