From: 7stud -- Date: 2008-05-17T13:27:23+09:00 Subject: Re: Object#select and method_missing Ray Baxter wrote: > On May 16, 2008, at 6:21 PM, Bob Aman wrote: > >> def test_two >> select() >> end >> end >> puts SelectTest.new.test_one >> puts SelectTest.new.test_two >> >> >> Anyone care to explain why test_one calls method_missing and test_two >> calls the private method Object#select? > > Object#select is a private method. Private methods cannot be called with > an explicit receiver. Your call self.select has an explicit receiver. > > Sounds like there should be a special exception for when the receiver is > self, but I could be missing something. > > Ray Why do both the method calls: sel() and self.sel() work in this code? module Kern def Kern.sel puts "select" end end class Obj include Kern end class Test < Obj def method_missing(meth_sym, *args) puts "method missing" end def meth1 puts "meth1" self.sel end def meth2 puts "meth2" sel end end t = Test.new t.meth1 t.meth2 --output:-- meth1 method missing meth2 method missing -- Posted via http://www.ruby-forum.com/.