Mega Code Archive

 
Categories / Ruby / Class
 

In Ruby, you prefix instance variables with an at sign @

# An instance variable is one in which you can store the data in an object - an instance of a class is an object.  # Instance variables hold their values for as long as the object is in existence.  # That's what helps make objects self-contained: the capability to store data. class Animal   def initialize     @color = "red"   end end