kishore.sayee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-01 18:45 UTC
Is Multiple Inheritance with Classes?
Hi, See the following code sinppet, I know we can mixin modules, but if i use modules, I wont be able to override the methods in modules. Can we inherit from more than one class? <html> <head> <script src="prototype_1_6.js"> </script> <script> var Person = Class.create({ initialize: function(name) { alert("init person"); this.name = name; }, say: function(message) { return this.name + '' person : '' + message; } }); var Intelligent = Class.create({ initialize: function(name) { alert("init intelligent"); this.name = name; }, sayin: function(message) { return this.name + ''intelligent : '' + message; } }); var Genius = Class.create(Person,Intelligent, { initialize: function(name) { this.name = name; }, tell: function($super, message) { return $super(message) + '', yarr!''; } }); </script> </head> <body> <script> var t = new Genius("X"); alert(t.say("Says hi")); //->X person Says hi alert(t.sayin()); // ->Throws javascript error - Object doesnt support this property or method </script> </body> </html> --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---