Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3486

Re: who can eplain deeply the ruby's methods?

From 7stud -- <bbxx789_05ss@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: who can eplain deeply the ruby's methods?
Date 2011-04-25 19:57 -0500
Organization Service de news de lacave.net
Message-ID <7b31d92cd9f02bc49d4ea27e46c14de7@ruby-forum.com> (permalink)
References <999670eb7a464b9d106f84fb7385d075@ruby-forum.com>

Show all headers | View raw


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/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

who can eplain deeply the ruby's methods? savin max <mafei.198@gmail.com> - 2011-04-24 00:57 -0500
  Re: who can eplain deeply the ruby's methods? Stu <stu@rubyprogrammer.net> - 2011-04-24 03:46 -0500
    Re: who can eplain deeply the ruby's methods? Stu <stu@rubyprogrammer.net> - 2011-04-24 03:58 -0500
    Re: who can eplain deeply the ruby's methods? savin max <mafei.198@gmail.com> - 2011-04-24 08:18 -0500
      Re: who can eplain deeply the ruby's methods? Stu <stu@rubyprogrammer.net> - 2011-04-24 15:53 -0500
        Re: who can eplain deeply the ruby's methods? savin max <mafei.198@gmail.com> - 2011-04-24 22:10 -0500
  Re: who can eplain deeply the ruby's methods? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-25 19:35 -0500
  Re: who can eplain deeply the ruby's methods? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-25 19:57 -0500
    Re: who can eplain deeply the ruby's methods? savin max <mafei.198@gmail.com> - 2011-04-26 05:06 -0500

csiph-web