From: "Hal E. Fulton" Date: 2002-09-24T09:52:41+09:00 Subject: Re: self as method argument revisited ----- Original Message ----- From: "Lloyd Zusman" To: "ruby-talk ML" Sent: Monday, September 23, 2002 7:23 PM Subject: Re: self as method argument revisited > "Gray, Jeff" writes: > > >> From: dblack@candle.superlink.net [mailto:dblack@candle.superlink.net] > >> > >> A while ago transami brought up the question of an object needing > >> access to the object that created it, and there was discussion of > >> techniques including sending self as an argument. > > > > I had my first Ruby epiphany when I was working on a netlisting > > tool where I needed to be able to traverse the hierarchy in > > both directions. When I wrote the following line of code in the > > "add a new block to the hierarchy" method: > > > > child.parent = self > > > > the profound, fundamental truth of that statement -- as bad of a > > programmer that I might be -- let me know that I was doing something > > right. :^) > > > > Cheers, > > > > - jeff > > We're lucky that Ruby doesn't also have a "spouse" keyword, or else then > there would be ambiguity, since the following would also be true: > > child.parent = spouse > > :) Now you're talking multiple inheritance. Or genetic algorithms. :) Hal