Skip to content

Instantly share code, notes, and snippets.

@lgmkr
Created April 4, 2013 22:38
Show Gist options
  • Save lgmkr/5314988 to your computer and use it in GitHub Desktop.
Save lgmkr/5314988 to your computer and use it in GitHub Desktop.
ruby global variables
$: contains an array of paths that your script will search through when using require
>>$:
#=> [".", "/Users/path/.ruby", "/test/path"]
$0 script name
$* shorter for ARGV
$? returns the exit status of the last child process to finish
>>`pwd`
#=> '/path/to/'
>> $?
=> #<Process::Status: pid=17867,exited(0)>
>> `fake command` # This will fail
(irb):7: command not found: fake command
=> ""
>> $?
=> #<Process::Status: pid=17871,exited(127)>
$$ returns the process number of the program currently being ran.
(tto be con)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment