Tag Archives: scope

Ruby’s variable variables

Hello everyone,

This is a quick post that should help developers new to Ruby. It may also help out those that have been away from the language for a while. Its just a quick reference to Ruby’s variables and their respective scopes. I know I had a chart to keep it all straight when I first encountered the language.

  1. @ An instance variable
  2. [a-z] or _ A local variable
  3. [A-Z] A constant
  4. @@ A class variable
  5. $ A global variable

This information is easily found on the net if you know what you are looking for. I just posted it to help make it even easier to find for those that are new to Ruby, or new to code writing 🙂 .