From: Sebastian Hungerecker Date: 2007-08-15T04:24:45+09:00 Subject: Re: attr_* position in a class and their results Arno J. wrote: > class Vartest_before > def init > @instance_variable = "I belong to the instance" > end > > attr_accessor :instance_variable This defines a method instance_variable > def instance_variable > @instance_variable = "Forced" > end > end This defines the method instance_variable again. The version created by attr_accessor doesn't exist anymore. > class Vartest_after > def init > @instance_variable = "I belong to the instance" > end > > def instance_variable > @instance_variable = "Forced" > end > > attr_accessor :instance_variable > end This time it's the other way around: First you define the method with def, then you redefine it with attr_accessor. It's like doing def bla() 1 end def bla() 2 end Everytime you call bla, it will return 2 because the second definition overrides the first one. HTH, Sebastian -- NP: Metallica - Trapped Under Ice Jabber: sepp2k@jabber.org ICQ: 205544826