Changes

Jump to: navigation, search

Ruby Variable Scope

351 bytes added, 19:00, 15 November 2007
Ruby Global Variables
<tr><td>
<code>$?</code> </td><td> The exit status of last executed child process</td></tr></table>
 
For example we can execute the ''gets'' method to take input from the keyboard, and then reference the ''$_'' variable to retrieve the value entered:
 
<pre>
irb(main):005:0> gets
hello
=> "hello\n"
irb(main):006:0> $_
=> "hello\n"
</pre>
 
Alternatively we could find the process ID of the Ruby interpreter:
 
<pre>
irb(main):007:0> $$
=> 17403
</pre>

Navigation menu