From: MonkeeSage Date: 2006-09-25T05:05:11+09:00 Subject: Re: Adding a new method to a class Mickael Faivre-Macon wrote: > What is called the process of adding a new method of an already defined class ? Hi Mickael, I'm not sure of any official technical name but I often see "extend" used for a previously undefined method and "override" for redefining an existing method. > What if I want to declare a new class variable in the initialize method ? > 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 ? Well a @var is an instance variable, a class variable has two @, like @@var. but in either case, you would just add it (in ruby you just assign to a variable and it comes into existence, not need to "declare" them any special way). class Tree def initialize @cat = 'in it' @@dog = 'bark' end end Regards, Jordan