2006/5/19, Patrick Spence <patrick / pkspence.com>:
> Robert Klemme wrote:
> > PostError is a method of MyErrorLogger::ErrorLogger, i.e. of the class
> > instance.  errorLogger is an instance of MyErrorLogger::ErrorLogger so
> > it cannot know this method.
> >
> > Kind regards
> >
> > robert
>
> I understood that when an instance of a Method::Class has been created,
> the resulting object would inherit all the methods and properties it was
> based on. Now I'm confused!

It seems so.  What is a "Method::Class" in your terminology?

Ok, I try again.  All classes are objects but not all objects are
classes.  A class defines instance methods. These methods can be used
in instances of the class and instances of sub classes.  Every object
can also have singleton methods (there are other names for them as
well but I'll stick with the convention Matz has founded); singleton
methods are present in that single instance only, there is no
inheritance associated with them whatsoever but you can find them in
the singleton class (every object has one and the singleton class has
only one instance). Since a class is an object it can have singleton
methods. These do roughly the same as static methods in Java, i.e. the
operate on the class level.  Some code:

irb(main):001:0> class Foo
irb(main):002:1> def bar() # instance method
irb(main):003:2> "bar"
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> Foo.new.bar
=> "bar"
irb(main):007:0> Foo.bar
NoMethodError: undefined method `bar' for Foo:Class
        from (irb):7
        from :0
irb(main):008:0> f=Foo.new
=> #<Foo:0x3d0238>
irb(main):009:0> f.bar
=> "bar"
irb(main):010:0> def f.special() # singleton method
irb(main):011:1> "buh!"
irb(main):012:1> end
=> nil
irb(main):013:0> f.special
=> "buh!"
irb(main):014:0> Foo.new.special
NoMethodError: undefined method `special' for #<Foo:0x3b5b38>
        from (irb):14
        from :0
irb(main):015:0> def Foo.nana() # singleton method
irb(main):016:1> "nana"
irb(main):017:1> end
=> nil
irb(main):018:0> Foo.nana
=> "nana"
irb(main):019:0> Foo.new.nana
NoMethodError: undefined method `nana' for #<Foo:0x3a8ff8>
        from (irb):19
        from :0

Hope it helps...

robert

-- 
Have a look: http://www.flickr.com/photos/fussel-foto/