Austin Ziegler <austin / halostatue.ca> wrote in message news:<20031228132838.011860 / PADD>... > On Sun, 28 Dec 2003 18:51:50 +0900, GGarramuno wrote: > > Okay, I am trying to clarify the use of nil in Ruby. > > When you set a variable to nil, Ruby seems to make the variable a > > nil object. > > > Now, is there a way to actually delete the variable from memory? > > Why? > Couple of reasons: 1) Memory While setting the variable to an empty class object would likely work for most cases, some scripting languages make the distinction so that the memory manager will not do more work than needed when either the memory can be reused somewhere else or when the memory will be reused by the same object to fill it back again. 2) Avoid namespace clashes In the past day or so I've been playing with ruby, I read about ruby's design flaw regarding local scopes. If a variable could be removed from scope, it would perhaps be a way of addressing some potential pitfalls, but I guess not. > > Also, is there any simple construct to find if a variable is defined? > > defined? Doh! Thanks a lot guys for answering these silly questions. I will likely have some more in the upcoming days. So far I am really, really impressed with ruby. I am porting some very complex Perl code (Damian Conway's Perl argument parsing library, probably the best one in any language I've seen) and I am astonished at how few changes need to be made, while at the same time it is improving its readability.