Is it posible multiple Inheritance?

10 views
Skip to first unread message

buda

unread,
Oct 13, 2011, 12:05:51 PM10/13/11
to Prototype & script.aculo.us
I need to create class which is inhereted from enumerable module,
sortable class and observable class
Is it possible in one operation call?

Andrew Dupont

unread,
Oct 19, 2011, 7:30:15 PM10/19/11
to Prototype & script.aculo.us
Sadly, no. You can mixin any number of objects (like Enumerable), but
only one class.

buda

unread,
Oct 19, 2011, 9:50:52 PM10/19/11
to prototype-s...@googlegroups.com
Hi Andrew!

is it possible to realize extending of the class by in a way that at the end of this process would be called the initialization method of extension?
So I would be extend any class with such extensions with no need to create intermediate classes.
Often in such extension I need to add some properties to extended object and need to initialiaze them - initialization of extension would be the nice idea!

Andy

unread,
Oct 18, 2011, 12:43:41 PM10/18/11
to Prototype & script.aculo.us
Just use Object.extend()

var MyClass = Class.create();
Object.extend(MyClass.prototype, Enumerable);
Object.extend(MyClass.prototype, Sortable.prototype);
Object.extend(MyClass.prototype, Observable.prototype);

Object.extend(MyClass.prototype, {
// your methods
doSomething: function() ...
});

buda

unread,
Oct 22, 2011, 9:34:23 PM10/22/11
to Prototype & script.aculo.us
Thanks
Reply all
Reply to author
Forward
0 new messages