Skip to content

Instantly share code, notes, and snippets.

@avdi
Created November 1, 2011 00:14
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 avdi/1329476 to your computer and use it in GitHub Desktop.
Save avdi/1329476 to your computer and use it in GitHub Desktop.
Aliasing global variables in Ruby
$magic_word = "xyzzy"
alias $mw $magic_word
$mw = "please"
$mw # => "please"
$magic_word # => "please"
@avdi
Copy link
Author

avdi commented Nov 1, 2011

Note that assigning to the alias changes the original. This is what makes the English stdlib possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment