On 2002.08.11, ts <decoux / moulon.inra.fr> wrote:
>  ruby has inserted a proxy class [ROS::Persistence] before A
> 
>  In A#initialize when you call #super, ruby find the method
>  ROS::Persistence#initialize 

Beware of this, though:

    module M 
      def initialize
        puts "M"
      end
    end

    class A
      def initialize
        puts "A"  
      end
    end

    class B < A
      include M
      def initialize
        puts "B"
        super
      end
    end

    b = B.new
    B
    M

A#initialize doesn't get invoked.  To ensure this, we must
call #super from M#initialize:

    module M 
      def initialize
        puts "M"
        super
      end
    end

    b = B.new
    B
    M
    A

Of course, observe the order in which they get invoked, though.

And, requiring #initialize to invoke #super means that mixing
the module in with something like the String class becomes
tricky.

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)