Created
November 1, 2011 00:14
-
-
Save avdi/1329476 to your computer and use it in GitHub Desktop.
Aliasing global variables in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$magic_word = "xyzzy" | |
alias $mw $magic_word | |
$mw = "please" | |
$mw # => "please" | |
$magic_word # => "please" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that assigning to the alias changes the original. This is what makes the English stdlib possible.