1. Technology
Send to a Friend via Email


Variables are named references to objects. Ruby has a variety of variable types and scopes.

Everything You Need to Know About Variables
Variables are named references to objects in memory. Their several variants (local, instance, class, constant, etc) each have their own subtleties.

Local Variables and Bindings
Ruby has a no-surprise take on local variables, they're handled similarly in most programming languages. However, Ruby implements them differently than stack-based languages.

Instance Variables
Instance variables are some of the most common and important variables types in Ruby. They begin with the at sign (@) and allow objects to track their internal state.

Class Variables
Class variables in Ruby are more or less as you'd expect form an object oriented language. However, Ruby throws you a curveball you can use to your advantage.

Constant Variables
Ruby's idea of constant variables is mostly without surprise, however their implementation is not exactly "constant."

Global Variables
Global variables are not often used in Ruby, however, you should at least understand their usage should you ever encounter them.

What are Variables?
An explanation of what variables are and how they affect your Ruby program.

Using Variables in Ruby
Learn how to use variables in Ruby, assign them information using the assignment operator and pass to a variable using the "puts" function.

Ruby Annoyances: Variables Don't Have Type
To many programmers new to Ruby and dynamic languages in general, one annoyance or point of confusion is that variables don't have type.

Environment Variables
Using environment variables in Ruby.

Constants in Ruby
Like just about every programming language every conceived, Ruby supports constants. A constant is a variable whose value cannot be changed. However, in Ruby, this has some caveats.

You can opt-out at any time. Please refer to our privacy policy for contact information.

©2014 About.com. All rights reserved.