From: Lloyd Linklater Date: 2008-09-16T00:19:13+09:00 Subject: Re: Need someone who can help Dot Baiki wrote: > Lloyd Linklater wrote: >> I am glad that it helped, though it seems that you have more than you >> strictly seem to need. e.g. >> >> class AreaOfCircle >> >> PI = 3.14159265 >> >> def calc_area(radius) >> PI * radius**2 >> end >> end >> >> is plenty. Note: no parameter needed for the AreaOfCircle.new > > I totally agree. I just thought it's better to allocate this memory in > order to write "clean" code. I just started with Ruby a few days ago, > hence I'm a total beginner (also with the English language). > > If I don't do this "initialize" thing: no drawbacks? > > Baiki There should be no drawbacks. In fact, the radius is not known until the AreaOfCircle method is called so, in this case, initializing it is not required. The Area variable is not really used as far as we can see. You did put this into a class so it may be that it is used elsewhere. As far as memory allocation, it is not necessary. Ruby does all that automatically and needs no help from us. -- Posted via http://www.ruby-forum.com/.