From: Ilias Lazaridis Date: 2011-06-20T08:35:34+09:00 Subject: Re: CORE - Inconsistent Handling of Uninitialized Variables On 20 Ιούν, 01:01, Gary Wright wrote: > On Jun 15, 2011, at 5:00 PM, Ilias Lazaridis wrote: > > > I don't understand, why "p $xx" does not fail with and "not defined" > > error. > > Because the parser 'sees' the variable $xx and defines it before "p $xx" gets executed. [...] - (explanations, referring to why to locals cannot behave this way) I'll reduce this further down, dealing *only* with global variables. (Please, if possible, avoid comparisons to the other variable types.) - $x_void def make_nil_global(val) $x_undefined = val end p global_variables - Behaviour (ruby 1.9.2p180): $x_void is added to the the global_variables (undefined, nil) $x_undefined is added to the global_variables (undefined, nil) Expected Behaviour: $x_void is ignored (*not* added to global_variables, access would raise error) $x_undefined is added to the global_variables (undefined, nil) - I cannot see a use case, where placing $x_void into the global_variables is *necessary*. I possibly oversee something very fundamental, but the main rules for my expectations are: * variables come to existence when a value is assigned * if the value cannot be determined, "nil" is assigned . -- http://lazaridis.com