From: Robert Klemme Date: 2004-06-14T20:38:40+09:00 Subject: Re: undefine "Claus Spitzer" schrieb im Newsbeitrag news:a7c2a81904061400186bf233eb@mail.gmail.com... > Again, this is where it's useful to consider the OO approach and think > of variables as just the symbols you use to reference to objects. If > the symbol you're using is not assigned to any object (a.k.a. it > points to nil) then it it undefined. I know I'm picky, but 1) You don't "assign a symbol to an object". If at all it's the other way round: you assign an object to a symbol. But I'd rather say "you make the variable point to an instance". The symbol is just the representation of the memory location that holds a reference to some instance. 2) 'nil' is in fact a valid instance. It has methods that can be invoked safely: >> nil.to_s => "" >> nil.to_i => 0 >> nil.id => 4 This is different from Java where you get a NullPointerException if you try to invoke any methods on 'null'. I think you wanted to say the right thing but it was a bit ill formulated IMHO. Kind regards robert > > On Mon, 14 Jun 2004 05:50:55 +0900, tony summerfelt > wrote: > > > > On Sun, 13 Jun 2004 20:08:48 +0900, you wrote: > > > > in my particular case i'm thinking black box approach. i don't want > > the variable to 'exist' any more. > > > > i don't know if that's how it's thought of in perl, but when i > > undef($x), $x is no longer there for me to use unless i assign it > > something, and i can test that it isn't with: > > > > if ! defined($x) # do something. > > > > as long as ruby 'acts' the same way, it's all i need. > > > > > >