Thanks very much, I was wrong and I deleted my posting, I understand better
now.
One remaining question is inheriting array member, if a parent has array
member in prototype, is it possible to subclass it without any issue? I did
simple testing using "Extending anonymous instances described in
Encytemedia, it shows that the array object is shared by two different child
instances. Is there any way to get around this?
var Shape = Class.create();
Shape.prototype = {
initialize: function() {
this.options = "parent";
this.array = new Array("hj", "jenny");
}
}
var Square = Class.create();
Square.prototype = Object.extend(new Shape(), {
initialize: function() {
this.foo = 'I am foo';
}
});
var sq1= new Square();
var sq2= new Square();
sq1.array.push("third");
console.log(sq1.array); //prints ["hj", "jenny", "third"]
console.log(sq2.array); //prints ["hj", "jenny", "third"]
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---