Skip to content

Instantly share code, notes, and snippets.

@francisco-rojas
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francisco-rojas/db0d5faa3dea0f88a55d to your computer and use it in GitHub Desktop.
Save francisco-rojas/db0d5faa3dea0f88a55d to your computer and use it in GitHub Desktop.
Name Aliases Description
$! $ERROR_INFO The exception information message set by the last 'raise' (last exception thrown).
$@ $ERROR_POSITION Array of the backtrace of the last exception thrown.
$& $MATCH The string matched by the last successful pattern match in this scope.
$` $PREMATCH The string to the left of the last successful match.
$' $POSTMATCH The string to the right of the last successful match.
$+ $LAST_PAREN_MATCH The last group of the last successful match.
$1 to $9 The Nth group of the last successful regexp match.
$~ $LAST_MATCH_INFO The information about the last match in the current scope.
$= $IGNORECASE The flag for case insensitive, nil by default (deprecated).
$/ $INPUT_RECORD_SEPARATOR, $RS or $-0 The input record separator, newline by default.
$\ $OUTPUT_RECORD_SEPARATOR or $ORS The output record separator for the print and IO#write. Default is nil.
$, $OUTPUT_FIELD_SEPARATOR or $OFS The output field separator for the print and Array#join.
$; $FIELD_SEPARATOR, $FS or $-F The default separator for String#split.
$. $INPUT_LINE_NUMBER or $NR The current input line number of the last file that was read.
$< $DEFAULT_INPUT An object that provides access to the concatenation of the contents of all the files given as command-line arguments, or $stdin (in the case where there are no arguments). Read only.
$FILENAME Current input file from $&lt;. Same as $&lt;.filename.
$> $DEFAULT_OUTPUT The destination of output for Kernel.print and Kernel.printf. The default value is $stdout.
$_ $LAST_READ_LINE The last input line of string by gets or readline.
$0 Contains the name of the script being executed. May be assignable.
$* ARGV Command line arguments given for the script. Also known as ARGV
$$ $PROCESS_ID, $PID or Process.pid The process number of the Ruby running this script.
$? $CHILD_STATUS The status of the last executed child process.
$: $LOAD_PATH Load path for scripts and binary modules by load or require.
$" $LOADED_FEATURES or $-I The array contains the module names loaded by require.
$stderr The current standard error output.
$stdin The current standard input.
$stdout The current standard output.
$-d $DEBUG The status of the -d switch. Assignable.
$-K $KCODE Character encoding of the source code.
$-v $VERBOSE The verbose flag, which is set by the -v switch.
$-a True if option -a ("autosplit" mode) is set. Read-only variable.
$-i If in-place-edit mode is set, this variable holds the extension, otherwise nil.
$-l True if option -l is set ("line-ending processing" is on). Read-only variable.
$-p True if option -p is set ("loop" mode is on). Read-only variable.
$-w True if option -w is set.

Predefined Constants:

  • _FILE_ (current file)
  • _LINE_ (current line)
  • _dir_ (current directory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment