On 11/04/2008, Robert Klemme <shortcutter / googlemail.com> wrote:

> Be careful when testing issues that involve local variables in IRB.
>  Top level local variables such as these do behave differently in IRB.

Oh I see, thanks for reminding Robert.

#!/usr/bin/ruby
# nil-check.rb

begin
  p var1
rescue NameError => e
  puts e.message
end

var1 = nil if false
p var1

begin
  p var2
rescue NameError => e
  puts e.message
end

var2 = 'nothing' if false
p var2

>  Cheers
>
>  robert
>
>
>  --
>  use.inject do |as, often| as.you_can - without end
>
>


-- 
blog: http://tinyurl.com/2bjgvn,
ruby: http://www.ruby-lang.org/id/about

"Developer Time is expensive...
Servers are cheap...", Ezra Zygmuntowicz - Merb