From: "Peña, Botp" Date: 2004-01-24T19:47:20+09:00 Subject: Re: nuby: determine method passed and determine the receiver that rec eived the method Dan Doel [mailto:djd15@po.cwru.edu] humbly replied/asked: > >>ruby -w test1.rb > >> > >> > >"You ask for bark thru beethoven" > >"arf!arf!" > >"You ask for purr thru beethoven" > >"sorry, cannot do purr thru beethoven" > > > > > I don't think you can do this. > > Variable names are incidental, essentially they're just > pointers to the > underlying object. > > You can have more than one variable pointing to the same > object, so any > object could > have an infinite number of 'names' (theoretically). Really, objects > don't have a name, > variable names are just ways to help us remember which is which. > Why do you want to do this? Thank you for asking, sir Dan. I am a newbie, and am trying to build a lesson plan for learning oop for beginners like me and non-programmers -and my son fits the bill. I hope to finish it before summer so that me and my son can learn together. Reading Dave's PickAxe, I got to the portion of explaining to myself the concept of receiver and method. Hoping that I'd simplify things to learn first, I started off w a definition of a class without any methods defined (in my example, class Dog). I would then instantiate an object of that kind of class and bombard it with any methods I like. However, I was stuck on "how does one know what methods were passed". I want to do this so I can say (especially to my son), "See son, it (the dog) got what you asked for. Next, we will now let it do what we asked..."... I thought this was possible since there is a method_missing() method wc knows the method passed (-unfortunately it is missing :-).. I follow same reasoning of the receiver... (and of course I may be wrong). > > - Dan > kind regards -botp