Chapter 3: Proper Variable Usage
Anytime you need to store information in a Ruby program and access it later, you will be using some sort of variable. Which types of variables you use has a significant effect on your program's performance and maintainability. In this chapter, you'll learn about Ruby's different variable types and the advantages of using and naming them properly.
We will cover the following topics:
- Using Ruby's favorite variable type – the local variable
- Learning how best to use instance variables
- Understanding how constants are just a type of variable
- Replacing class variables
- Avoiding global variables, most of the time
By the end of this chapter, you'll have a better understanding of the different types of variables and how best to use them.