From: Gavin Sinclair Date: 2003-02-20T09:34:53+09:00 Subject: Re: How to test for existence of instance variable? On Thursday, February 20, 2003, 6:17:28 AM, Bill wrote: >> 3) Set the attribute to some value (the default value is nil, but >> depending on this value is not a good idea) > It seems one thing if you think the intent of the code is more > clearly expressed having redundant @var = nil expressions in the > object initializer; but, saying we'd be wrong somehow to depend on > Ruby guaranteeing variables' default value is nil? Why shouldn't > this be a behavior that's reasonable to depend on? Is it going to > change in the future? Ruby can't set instance variables to nil by default, can it? It doesn't know about them until it trips over them (i.e. there's no instance variable declaration), and the attr_accessor trick couldn't do it because it operates at a class level. # May be wrong... Gavin