What does the "$" character mean in Ruby?
$
identifies a global variable, as opposed to a local variable, @instance variable, or @@class variable.
Among the language-supplied global variables are $:
, which is also identified by $LOAD_PATH
$: is the global variable used for looking up external files.
From http://www.zenspider.com/Languages/Ruby/QuickRef.html#18
$: Load path for scripts and binary modules by load or require.
I wanna note something weird about Ruby!
$
does indeed mean load path. And ;
means "end line". But!
$;
means field separator. Try running $;.to_s
in your REPL and you'll see it return ","
. That's not all! $
with other suffixes can mean many other things.
Why? Well, Perl of course!