Hi lun.ashis,

the first part, creating the Animal class is OK.
For the Snake class, you'll create a new class based on Animal. So all
Animal methods will be avalaible in the Snake class. This is done by
this part:
var Snake = Class.create(Animal, { ...});

Next, you want to modify the Initialize constructor (which will be
called at the creation of a new instance of this class). You still
want to be able to call the original function from the Animal class.
That is what is done with the redefinition of the Initialize function.
Now first parameter is the va


On 5 juin, 05:59, "lun.ashis" <[email protected]> wrote:
> In prototype i found these example of the  class inheritance.
>
> var Animal = Class.create({
>   initialize: function(name, sound) {
>     this.name  = name;
>     this.sound = sound;
>   },
>
>   speak: function() {
>     alert(this.name + " says: " + this.sound + "!");
>   }
>
> });
>
> // subclassing Animal
> var Snake = Class.create(Animal, {
>   initialize: function($super, name) {
>     $super(name, 'hissssssssss');
>   }
>
> });
>
> Can anyone explain me this.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to