>On Jun 15, 2004, at 10:19 AM, tony summerfelt wrote:
>I think the whole point here is that it isn't Ruby-ish to rely on a variable being defined or not. Ruby wassn't built to do things in that way; a couple examples in this thread show how variables are automagically defined when code is parsed. They aren't defined at runtime, they are defined at eval time.

For the sake of it:

def test(); p defined? x; x = "hello"; p defined? x; end
test() # => nil, "local-variable"

According to the definition of "defined" implemented by
defined?(), it appears that in fact a local variable is
not defined until it gets assigned. That necessarily
happens at runtime. However, at parse time (or eval time),
the compiler determines that some entity is going to be
a local variable... once it gets defined at runtime.

This is a very minor thing and I would be surprised
to seen some example of code taking advantage of that
behavior of defined?()

Yours,

JeanHuguesRobert



-------------------------------------------------------------------------
Web:  http://hdl.handle.net/1030.37/1.1
Phone: +33 (0) 4 92 27 74 17