Ruby: "nameerror: uninitialized instance variable" error

Example:

class Example
  def print_var
    puts @an_instance_var
  end
end
Example.new.print_var
Occurs when you reference an uninitialized instance variable.

Solution:

@an_instance_var ||= "Default value"

Beginner's Guide to Ruby