From: Mauricio Fernandez Date: 2006-06-06T05:11:45+09:00 Subject: Re: An alternative to the class Foo < Struct.new(vars) idiom and SuperStruct On Fri, Jun 02, 2006 at 02:35:26AM +0900, ara.t.howard@noaa.gov wrote: > >Would def sum; @a + @b end also work? > >Plain instance variables are the main appeal of SuperStruct or SuperClass. > > yes. > > >Interesting. Can this be made to work if X is defined as > > class X > > attr_reader :foo > > def initialize(foo); @foo = foo end > > end > >and doesn't include TraitInit, or when it does something non-trivial in > >#initialize? In other words, is it possible to have a single class in the > >hierarchy use traits' trait_initialize without touching the rest? > > yes. [...] > > >And is the block evaluated every time one calls #foo, or only once? > > only once. [...] Thanks for taking the time to answer my questions; it seems traits is very well-behaved indeed :) -- Mauricio Fernandez - http://eigenclass.org - singular Ruby