TIL: English Ruby
Banishing cryptic constant names
Ruby has a stdlib module called English
that gives you meaningful names as aliases for the cryptic built-in globals.
All you need to do is:
require 'English'
(Yes, that's a require with a titlised module name)
Constant | Alternative |
---|---|
$! |
$ERROR_INFO |
$@ |
$ERROR_POSITION |
$; |
$FIELD_SEPARATOR |
$, |
$OUTPUT_FIELD_SEPARATOR |
$/ |
$INPUT_RECORD_SEPARATOR |
$\ |
$OUTPUT_RECORD_SEPARATOR |
$. |
$INPUT_LINE_NUMBER |
$_ |
$LAST_READ_LINE |
$> |
$DEFAULT_OUTPUT |
$< |
$DEFAULT_INPUT |
$$ |
$PROCESS_ID |
$? |
$CHILD_STATUS |
$~ |
$LAST_MATCH_INFO |
$= |
$IGNORECASE |
$* |
$ARGV |
$& |
$MATCH |
$` |
$PREMATCH |
$' |
$POSTMATCH |
$+ |
$LAST_PAREN_MATCH |
Member discussion