On Mon, Dec 14, 2009 at 9:37 PM, Brian Candler <b.candler / pobox.com> wrote:

>
> In addition: Objects have singleton classes, which are private to that
> object. You can use 'extend' to add a module to an individual object's
> singleton class.
>
> module Foo
> def greet
>  puts "Hello, #{self}!"
> end
> end
> s = "you"
> s.extend Foo
> s.greet     # => "Hello, you!"
>
> Note we have not touched class String at this point.
>
> But since classes are objects too, the same applies to classes. You can
> use a module to add "class methods" to a class.
>
> String.extend Foo
> String.greet  # => "Hello, String!"
>

Thanks for the points. That looks very interesting.
As you said "Objects have singleton classes", what's "singleton
class"? could you show a description by examples?
I never saw that before. Thanks again.