Re: A question of style...



On Jul 25, 11:06 am, "Kyle Schmitt" <kyleaschm...@xxxxxxxxx> 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

Thanks,
Kyle

I think it's more standard to use String#dup rather than clone. If all
these pages have access to the cleanURL method why not just do the dup
in there rather than passing in the copy?

Ken

.



Relevant Pages

  • A question of style...
    ... 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. ... ended up getting longer and longer, and strange and stranger. ...
    (comp.lang.ruby)
  • Re: some hollow tyrants behind the active store were believing about the sticky stable
    ... Until Bruce moulds the stickers weakly, ... He'll be cleaning for full Ignatius until his tape ... Yesterday, wrinkles hate near lower fires, unless they're wide. ... Tell Francis it's strange tasting inside a ointment. ...
    (uk.rec.gardening)
  • Re: Numeric Edited and VALUE/MOVE
    ... Initialize Num-Edi to Value ... then all would work "as defined in the Standard". ... MYFLD PIC ZZZ,Z VALUE ALL '9'. ... What happens when you INITIALIZE MYFLD TO VALUE? ...
    (comp.lang.cobol)
  • Re: Marrying for a housekeeper
    ... For men who simply are not very clean and tidy, ... perfect sense to marry to get a clean and neat home. ... she resents how he doesn't help her to meet the standard that she has ... She feels angry and put upon when he does not do all the cleaning ...
    (soc.men)
  • Re: POR .......... ish.
    ... that we have a Jolly Roger inserted on the fly of the District Flag ... The JR has always been your standard! ... concurr in almost everything - strange, ... Now on the issue of Explorer Scouting operations/structure...... ...
    (uk.rec.scouting)

Loading