From: "Földes László" Date: 2012-04-11T04:53:49+09:00 Subject: Re: New to Ruby, tutorial gives wrong example. Roger McDonald wrote in post #1055746: > > Just this required the same text 3 times, one to initialise, one to > declare variables and one for attr_accessor > It might seem awkward, but Ruby is such a language where: 1. you cannot access an initiated class' variables by default (there is a way, but that looks ugly). 2. (almost) everything is a method These concludes that if you want to access the variables of a class, you have to write methods for that. That's what 'attr_accessor' did, and it did saved you a lot of typing :-) As for the 'initialize', it is not necessary to initialize variables during that phase, but then you would have to do that later, through the methods that attr_accessor created. class Rectangle attr_accessor :y, :x, :height, :width, :linecolor, :fillcolor, :linewidth end rect = Rectangle.new() rect.y, rect.x, rect.height, rect.width, rect.linecolor, rect.fillcolor, rect.linewidth = 10, 20, 50, 60, "blue", "yellow", 12 (you can rewrite your initialize method with multiple assignment as above, it will be more compact and readable) -- Posted via http://www.ruby-forum.com/.