On Sun, Feb 10, 2013 at 4:09 AM, tamouse mailing lists <tamouse.lists / gmail.com> wrote: > Something like: > > 1.9.3-head :065 > b = a + 1 > > raises an exception if a is not defined: > > NameError: undefined local variable or method `a' for main:Object > from (irb):65 > from /home/tamara/.rvm/rubies/ruby-1.9.3-head/bin/irb:16:in `<main>' > > Is there a more elegant way to check if a is defined besides wrapping > it in begin/rescue/end block? Something along the order of: You can use a rescue modifier: $ ruby -e 'b = a + 1 rescue 99; p b' 99 Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/