From: Siep Korteling Date: 2008-10-23T08:04:34+09:00 Subject: Re: neatest way to extend Struct Martin DeMello wrote: > I want a Structlike class that takes a hash constructor, so I can say > > class A < MyStruct.new(*keys); end > > a = A.new(:key1 => val1, :key2 => val2) > > Is there any way to base this off Struct? > > martin It'standard: require 'ostruct' (...) hash = { "country" => "Australia", :population => 20_000_000 } data = OpenStruct.new(hash) p data # -> (code from documentation) hth, Siep -- Posted via http://www.ruby-forum.com/.