Stefano Crocco
7/29/2008 10:41:00 AM
On Tuesday 29 July 2008, Kyung won Cheon wrote:
> -- test1.rb --
>
> class C
> def a
> end
> end
>
> class C
> def a
> puts "override"
> end
> end
>
> puts C.new.a # => override
>
> -- test2.rb --
>
> class C
> def a
> end
> end
>
> module M
> class C
> def a
> puts "why not override?"
> end
> end
> end
>
> include M
>
> puts C.new.a # => nil
>
> ########################
> # Help Me^^
> ########################
C and C::M are two different classes. Modules work as namespaces, so that you
can have different classes with the same name, provided they're in different
modules.
Stefano