From: Tanner Burson Date: 2007-07-26T00:24:58+09:00 Subject: Re: A question of style... ------=_Part_74571_8706796.1185377099358 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/25/07, Kyle Schmitt wrote: > > I just had a funny thing happen. > I've got a bunch of classes that take a url for their initialize > methods, and do a little cleaning on the url, just in case. > > I was setting them all up like this > @url = "http://localhost:1948/" > @one = pageOne(@url) > @two = pageTwo(@url) > @three = pageThree(@url) > > Because of the housekeeping & pass-by-reference being standard, @url > ended up getting longer and longer, and strange and stranger. > > I know a dozen fairly easy ways of solving this problem, but my > question is, what is the _right_ way to solve it in ruby? > > I could easily do this in the SuperPage class that all the pages > inherit from, but it seems a tad awkward. Then again so do some of > the other ideas I have. > > def initailize(url) > @url=cleanURL(url.clone) > end It looks like your page* and cleanURL methods are in the same class as the one you're initializing? If this is the case why not just access @url directly in the methods, and avoid passing it to them entirely? Thanks, > Kyle > > -- ===Tanner Burson=== tanner.burson@gmail.com http://www.tannerburson.com ------=_Part_74571_8706796.1185377099358--