From: Ilias Lazaridis Date: 2011-06-20T05:45:30+09:00 Subject: Re: CORE - Inconsistent Handling of Uninitialized Variables (slightly corrected, order of variable types) puts "\n== Testin in MAIN Context ==" $global = 'global' @instance = 'instance' @@class = 'class' local = 'local' puts "#$global, #@instance, #@@class, #{local}" begin puts $empty_global == nil rescue puts "undefined" end begin puts @empty_instance == nil rescue puts "undefined" end begin puts @@empty_class == nil rescue puts "undefined" end begin puts empty_local == nil rescue puts "undefined" end class VarTest puts "\n== Testin in Class Context ==" $global = 'global' @instance = 'instance' @@class = 'class' local = 'local' puts "#$global, #@instance, #@@class, #{local}" begin puts $empty_global == nil rescue puts "undefined" end begin puts @empty_instance == nil rescue puts "undefined" end begin puts @@empty_class == nil rescue puts "undefined" end begin puts empty_local == nil rescue puts "undefined" end end #OUTPUT == Testin in MAIN Context == global, instance, class, local true true undefined undefined == Testin in Class Context == global, instance, class, local true true undefined undefined > The inconsistency: > > become nil, do not raise error: > $empty_global > @empty_instance > > are undefined, raise an error: > empty_local > @@empty_class > > - > > Is this a defect or is there an explanation for this behaviour? -- http://lazaridis.com