From: Trans Date: 2006-07-23T10:55:12+09:00 Subject: Re: Set an instance variable before and after initialize Martin Jansson wrote: > If possible, I would like to set a instance variable in an object before > and after its initialize method is executed. > > I've been looking at Class#new but it doesn't seem to have access to a > reference to the object in creation. class Klass def self.new( *args, &blk ) o = allocate o.instance_variable_set( "@foo", "anything") o.initialize( *args, &blk ) o.instance_variable_set( "@bar", "anything") o end You could also you #instance_eval { @foo = "anything } T.