Local Variable

A local variable for a method or block (gone when the method is done).

age = 21

Instance Variable

A instance variable owned by each object (it sticks around).

@age = 21

Class Variable

A class variable shared by all objects (it sticks around, too).

@@age = 21

Global Variable

A global variable can be referred to from anywhere in a program.

$age = 21

Constant Variable

A constant variable is like a regular variable, except that its value is supposed to remain constant for the duration of a program.

AGE = 21

Last updated