Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: 7stud -- Newsgroups: comp.lang.ruby Subject: Re: who can eplain deeply the ruby's methods? Date: Mon, 25 Apr 2011 19:57:46 -0500 Organization: Service de news de lacave.net Lines: 31 Message-ID: <7b31d92cd9f02bc49d4ea27e46c14de7@ruby-forum.com> References: <999670eb7a464b9d106f84fb7385d075@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303779501 29636 65.111.164.187 (26 Apr 2011 00:58:21 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Tue, 26 Apr 2011 00:58:21 +0000 (UTC) In-Reply-To: <999670eb7a464b9d106f84fb7385d075@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382174 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <7b31d92cd9f02bc49d4ea27e46c14de7@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3486 a) Singleton methods are inserted into an anonymous class immediately above the object in the method lookup chain. b) The methods in an included module are also inserted in an anonymous class immediately above the class/module that does the include()'ing. One tricky part of the method lookup: class methods are inherited by subclasses: class Parent def self.greet puts 'Hi!' end end class Child < Parent def self.cry puts 'Weeep, weep!' end end Child.cry Child.greet --output:-- Weeep, weep! Hi! -- Posted via http://www.ruby-forum.com/.