From: Bertram Scharpf Date: 2009-08-19T12:28:43+09:00 Subject: Re: if defined on var Hi, Am Mittwoch, 19. Aug 2009, 11:22:18 +0900 schrieb Derek Smith: > table_exists = db.execute( ...) > > if defined?(table_exists) > p "yes" > end > exit > > Why does this print "yes"? irb(main):001:0> x = nil => nil irb(main):002:0> defined? x => "local-variable" irb(main):003:0> defined? y => "method" irb(main):004:0> defined? z => nil ^^^ ^^^^^ irb(main):005:0> y ArgumentError: wrong number of arguments (0 for 1) from (irb):5:in `y' from (irb):5 irb(main):006:0> Ugh, I did not know that `y' is a method. Be aware that `defined?' is not an operator but examines the next token. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de