From: tamouse mailing lists Date: 2013-02-10T12:09:02+09:00 Subject: elegant way to determine if something is defined 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 `
' 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: Object.defined?('a') (I'm probably thinking about this wrong...)