Changes

Jump to: navigation, search

Ruby Variable Scope

131 bytes added, 19:20, 15 November 2007
Detecting the Scope of a Ruby Variable
== Detecting the Scope of a Ruby Variable ==
Obviously, you can tell the scope of a variable by looking at the name. Sometime, you need to find out the scope programmatically. A useful technique to find out the scope of a variable is to use the ''defined?'' method. ''defined?'' will return the scope of the variable referenced, or ''nil'' if the variable is not defined in the current context:
<pre>

Navigation menu