
Polished Ruby Programming
By :

Ruby's favorite variable type is the local variable. Local variables are the only variable type that Ruby doesn't require you to use a sigil (for example, @
or $
) or use capitalization. This is not by accident, this is by design, to nudge you toward using local variables as much as possible.
In this section, you'll learn how to improve performance by adding local variables, when it's safe to do so, issues involving scope gates, and the importance of local variable naming.
You may be wondering, Why are local variables better than other types of variables? In Ruby, all other variable types require more indirection. Local variables require the least indirection. When you access a local variable in Ruby, the virtual machine knows the location of the local variable, and can more easily access the memory. Additionally, in most cases, the local...