From: tamouse mailing lists Date: 2013-02-13T12:36:23+09:00 Subject: Re: elegant way to determine if something is defined On Sat, Feb 9, 2013 at 9:20 PM, Adam Prescott wrote: >> Object.defined?('a') > > defined?(a) #=> nil > b = a + 1 #=> NameError > a = 1 > defined?(a) #=> "local-variable" (strings are truthy) > > However, relying on defined?(a) to check for local variables is > probably a code smell: they're local variables, why isn't the code > just written properly? What's the problem you're trying to solve? > You've pretty much hit the nail on the head there -- legacy code, much of it not very well thought out, etc. Some of this is debugging (de-smelling? SANITIZING!)