

Cryptic Ruby Global Variables and Their Meanings - briangonzalez
http://jimneath.org/2010/01/04/cryptic-ruby-global-variables-and-their-meanings.html

======
telemachos
For a longer list (though the explanations are briefer), see Zenspider's Ruby
QuickRef[1]. It also includes a handy listing of predefined global
constants[2] (and a lot more).[3]

[1]: [http://zenspider.com/Languages/Ruby/QuickRef.html#pre-
define...](http://zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-
variables)

[2]: [http://zenspider.com/Languages/Ruby/QuickRef.html#pre-
define...](http://zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-
global-constants)

[3]: <http://zenspider.com/Languages/Ruby/QuickRef.html>

~~~
dlisboa
$YOUR_RUBY_PATH/lib/ruby/1.9.1/English.rb has the full list, with pretty
decent explanation.

~~~
twelvechairs
also here
[http://stdlib.rubyonrails.org/libdoc/English/rdoc/files/Engl...](http://stdlib.rubyonrails.org/libdoc/English/rdoc/files/English_rb.html)

~~~
Empact
Yep, if you must use the variables, much much better to use "require
'english'" and these more meaningful names than the cryptic originals.

------
ef4
This is one area where Matz kept too much of Perl. Thankfully, it's rare to
see Ruby programmers making heavy use of these.

~~~
briangonzalez
True, but I have seen -- $:.unshift File.dirname(__FILE__) -- used quite a bit
in the wild, especially in MacRuby projects.

~~~
vidarh
$: and $1 .. $9 are relatively frequently used. Most of the other ones are
rare - several of them I've never seen used at all.

------
damncabbage
When using the debugger you can sometimes end up in an exception handler that
doesn't provide a way to get access to said exception. $! can be a life-saver
to help figure out what's going on, eg.

    
    
      (rdb:1) list
         11    do_something_stupid
         12  rescue
      => 13    log("Something went wrong")
         14  end
     
      (rdb:2) e $!
      #<Errno::ENOENT: No such file or directory - /tmp/durr>

------
Xylakant
I rarely see those used except when you look at codegolf contests. There you
can find all of those variables put to good and creative use :)

