------art_17273_8909204.1159130318637
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On 9/24/06, Mickael Faivre-Macon <faivrem / gmail.com> wrote:
>
> Hi,
>
> What is called the process of adding a new method of an already defined
> class ?


Actually that is the *only* way to add a method to a class. In Ruby the
class is already defined inside it's declaration, for what I think one of
the many brilliant ideas of Matz.
Look at this code for demonstration
def who_am_I *objs
    objs.each do
        |obj|
        p "#{obj.name}:#{obj.class} @ %08x " % obj.object_id
    end #objs.each do
end

class A
    who_am_I self
    def a; 42; end
end
who_am_I A
class A
    who_am_I self
    def b; 1764; end
end


For example:
>
> class A
>    def a
>    end
> end
>
> And in another file:
>
> class A
>    def b
>    end
> end


which would be the same as
class A
   def a
   def b
end

And now my real question:
>
> What if I want to declare a new class variable in the initialize method ?


Robert had already answered that 1 brilliantly, so why should Robert answer
that one brilliantly?

If it's a derived class I can call super:
> def initialize
>    super
>    @my_var = ""
> end
>
> but if it not derived ?
> How can I do this ?
>
> Thanks,
> Mickael
>
>
Cheers
Robert

-- 
Deux choses sont infinies : l'univers et la bóŐise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein

------art_17273_8909204.1159130318637--