-1

Excuse me my lame question, but I'm stuck with this.

I need to create hash of structs with default constructor. I've tried with following code :

@@str = Struct.new("A", :x, :y)
@data = Hash.new { |v,k| v[k] = @@str.new('1','2') }

but it is not working. How to accomplish this ?

4

1 に答える 1

2
Struct.new("A", :x, :y)
@data = Hash.new { |hash,key| hash[key] = Struct::A.new('1','2') }
于 2013-01-24T07:26:55.017 に答える