Cryptic Ruby Global Variables and Their Meanings
jimneath.org
jimneath.org
[1]: http://zenspider.com/Languages/Ruby/QuickRef.html#pre-define...
[2]: http://zenspider.com/Languages/Ruby/QuickRef.html#pre-define...
perldoc English
perldoc perlvar
links: http://perldoc.perl.org/English.html | http://perldoc.perl.org/perlvar.htmlIMO they can make code easier to understand, once you've learned what they mean. $2 conveys the same idea as matches[2] without having to think about array indices, and why the matches aren't zero-indexed like a normal array. This is obviously totally subjective.
foo.map { |x| x.something rescue $! } {
# level 1
local $\ = "[1]\n";
some_print_operation();
{
# level 2
local $\ = "[2]\n";
some_print_operation();
}
# level 1 again
some_print_operation();
}
# $\ back to what it was before all this :) (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>