From: Martin DeMello Date: 2008-10-23T08:42:45+09:00 Subject: Re: neatest way to extend Struct On Wed, Oct 22, 2008 at 4:34 PM, David A. Black wrote: > > Do you need to use inheritance, as opposed to just instantiating > MyStruct directly? I'm thinking of, for example: > > class MyStruct < Struct > def self.new(*keys) > s = super > s.class_eval do > define_method(:initialize) do |hash| > hash.each {|k,v| send("#{k}=",v) } > end > end > s > end > end Doh - of course, since you aren't inheriting from Struct, you shouldn't be inheriting from MyStruct either :) Wasn't thinking clearly enough about the problem. Thanks! martin