From: Ashley Moran Date: 2006-07-26T16:43:10+09:00 Subject: Re: get caller of method On Sunday 23 July 2006 22:55, Sean O'Halpin wrote: > Hi, > > It's not clear to me what you're doing with the binding. You don't > need it for your example and it won't work the way you seem to think. > > The example below shows you don't need to do anything fancy to get hold of > self: > < SNIP bit that shows me up as clueless :) > > > Please feel free to correct me if I've gotten hold of the wrong end of > the stick (it has been known ;) > > Regards, > Sean Hi Sean Seems I misunderstood the scope of "self". I assumed that since a Food instance was calling a method in another object (the application instance of Object) that self would be the global "main" object. IE: irb(main):003:0> class Foo irb(main):004:1> def test irb(main):005:2> global_test irb(main):006:2> end irb(main):007:1> end => nil irb(main):008:0> def global_test irb(main):009:1> puts self.class irb(main):010:1> puts self.inspect irb(main):011:1> end => nil irb(main):012:0> Foo.new.test I expected: Object main But you actually get: Foo # I have to say, I don't understand this behaviour. Maybe I am missing something. I assume it is to do with class nesting? Ashley -- "If you do it the stupid way, you will have to do it again" - Gregory Chudnovsky