Trans
11/18/2007 11:15:00 PM
On Nov 17, 5:23 pm, "Robert Dober" <robert.do...@gmail.com> wrote:
> On Nov 17, 2007 10:07 PM, Gregory Seidman
>
>
>
> <gsslist+r...@anthropohedron.net> wrote:
>
> > On Sun, Nov 18, 2007 at 01:47:53AM +0900, Trans wrote:
> > > Given that a hash is not ordered, is this reliable?
>
> > > h = { :a=>1, :b=>2 }
> > > Struct.new(*h.keys).new(*h.values)
> > > => #<struct #<Class:0xb7aead00> a=1, b=2>
>
> > It should work, but it causes me discomfort, too. I prefer this:
>
> > k,v = h.to_a.transpose
> > Struct.new(*k).new(*v)
> that is nice
Thanks all. Good to understand --notably the thread safety. I'll use
Robert's or Greg's suggestion.
Seems like it would be nice to have a way to generate a one time
Struct object like one can an OpenStruct. But in anycase....
Thanks,
T.