public
Created

Aliasing global variables in Ruby

  • Download Gist
alias.rb
Ruby
1 2 3 4 5 6
$magic_word = "xyzzy"
alias $mw $magic_word
$mw = "please"
 
$mw # => "please"
$magic_word # => "please"

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.