Changes

Jump to: navigation, search

Ruby Variable Scope

10 bytes added, 21:15, 30 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. SometimeSometimes, however, 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