Ruby’s variable variables2009-08-31
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.
- @ An instance variable
- [a-z] or _ A local variable
- [A-Z] A constant
- @@ A class variable
- $ 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 🙂.