From: Albert Schlef Date: 2010-02-19T16:06:44+09:00 Subject: Re: Ruby conditionals subtlety? Farhad Farzaneh wrote: >> I should also point out: almost all of this is of no consequence. You >> almost never use defined? on a local variable like this. You usually use >> it on a const, ivar, cvar, or global, and all of those are unambiguous. > > Thanks. I sometimes use it in Rails partials rendering, where I may > pass an optional local variable, but if it isn't passed, I want to set > it to some default value. BTW, I wonder, In templates, local variables are created dynamically (e.g., the programmer passes a hash of "variables" to the template engine). So how can Ruby know, in the template code, that a "name" refers to a variable? By default Ruby thinks names are method invocations and since there's no assignment, Ruby has no way to know these are variables... -- Posted via http://www.ruby-forum.com/.