From: 7stud -- Date: 2009-04-01T00:33:04+09:00 Subject: Re: When to use instance variables @ 7stud -- wrote: >> 3) I've seen code where just below the class declaration, objects are >> instantiated like product = Product.new - I don't see a @ sign, does >> that mean it's a local var? How can a local var even exist at the class >> level, outside a function? >> > class Product attr_accessor :product def initialize @product = "Shoes" end end class Person PersonProduct = Product.new def initialize(name, age, product) @name = name @age = age @product = product end def show puts "We all have #{PersonProduct.product}" puts "And I have #{@product}" end end p = Person.new("Steve", 25, "Sandals") p.show --output:-- We all have Shoes And I have Sandals -- Posted via http://www.ruby-forum.com/.