From: Robert Klemme Date: 2008-10-23T16:19:17+09:00 Subject: Re: neatest way to extend Struct 2008/10/23 Martin DeMello : > On Wed, Oct 22, 2008 at 11:03 PM, Robert Klemme > wrote: >> >> Why inheritance at all? Why do too much? > > Because I'd have to repeat that for every new struct I created. But > that's a very neat trick indeed! Oh, you want another Struct implementation that does this? I wasn't aware of this. That's easily fixed. class MyStruct < Struct def initialize(h={}) members.each {|m| self[m] = h[m.to_sym]} end end s1 = MyStruct.new :foo, :bar p s1.ancestors, s1.new(:bar => 123) Kind regards robert -- remember.guy do |as, often| as.you_can - without end