From: Jamey Cribbs Date: 2005-10-28T01:55:48+09:00 Subject: Re: Initializing a Struct from an array John Lam wrote: >I'm writing some code to dump database tables into in-memory hashtables. >Here's an example: > >Foo = Struct.new('Foo', :id, :a, :b, :c) >conn.select_all('select * from foo').each do |h| >current = Foo.new(h[0], h[1], h[2], h[3]) >@foo_map[current.id ] = current >end > >It's the Foo.new ... part that bugs me. Is there a nice clean way of >initializing a Struct from an array? > > current = Foo.new(*h)