From: "Jakub PavlĂ­k jn." Date: 2009-01-25T10:09:15+09:00 Subject: Re: Not sure why this is failing, barring a typo: > This code, directly from a book: > > class Animal > def initialize(color) > @color = color > end > > def get_color > return @color > end > end > > animal = Animal.new("brown") > puts "The new animal is " + animal.color > > results in "undefined method: color". But aren't I defining the method > as part of the constructor? Maybe I just don't understand what I'm > doing... anyhow, help would be appreciated! :) > > -Alex No. @color = color just defines instance variable, which can't be accessed from outside. You must define reader method: attr_reader :color or def color return @color end -- "Configure complete, now type 'make' and PRAY." (configure script of zsnes - www.zsnes.com)