J
John Lam
------=_Part_4331_20153101.1130431923854
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I'm writing some code to dump database tables into in-memory hashtables.
Here's an example:
Foo =3D Struct.new('Foo', :id, :a, :b, :c)
conn.select_all('select * from foo').each do |h|
current =3D Foo.new(h[0], h[1], h[2], h[3])
@foo_map[current.id <http://current.id>] =3D current
end
It's the Foo.new ... part that bugs me. Is there a nice clean way of
initializing a Struct from an array?
Thanks
-John
http://www.iunknown.com
------=_Part_4331_20153101.1130431923854--
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I'm writing some code to dump database tables into in-memory hashtables.
Here's an example:
Foo =3D Struct.new('Foo', :id, :a, :b, :c)
conn.select_all('select * from foo').each do |h|
current =3D Foo.new(h[0], h[1], h[2], h[3])
@foo_map[current.id <http://current.id>] =3D current
end
It's the Foo.new ... part that bugs me. Is there a nice clean way of
initializing a Struct from an array?
Thanks
-John
http://www.iunknown.com
------=_Part_4331_20153101.1130431923854--