From: 7stud *** Date: 2007-09-01T12:58:11+09:00 Subject: Re: attr_reader Pe単a, Botp wrote: > From: 7stud 7stud [mailto:dolgun@excite.com] > # "The corresponding instance variables, @name, @artist, and @duration, > # will be created for you." > > that should read: "The corresponding instance variable getter and setter > methods will be created for you." > Huh? As far as I can tell, no setter methods are created: class Song attr_reader :x, :y, :z def initialize(x, y, z) @x = x @y = y @z = z end end s = Song.new (10, 20, 30) puts s.x s.x = 40 --output:-- 10 r1test.rb:22: undefined method `x=' for # (NoMethodError) > > #So, it seems like initialize is what creates the instance variables. > > not really. > > irb(main):097:0> class Song2 > irb(main):098:1> attr_accessor :x, :y > irb(main):099:1> end > => nil > > note, no initialization there > My program has no attr_accessor line (the book hasn't mentioned attr_accessor yet). Your saying the initialize method in my program doesn't create the instance variables? What does? -- Posted via http://www.ruby-forum.com/.