4 ms·
You can't change the inheritance as far as I know after creation without some hacks, but you can change the class that an instance refers to which can kinda sor
by status_quo69 7y ago
You can't change the inheritance as far as I know after creation without some hacks, but you can change the class that an instance refers to which can kinda sorta achieve the same thing. You can't necessarily add properties to a base class and have all of those reflect immediately unless you use some hackery with class properties.
Example: https://github.com/dabeaz/python-cookbook/blob/master/src/8/implementing_stateful_objects_or_state_machines/example1.py#L5 https://github.com/dabeaz/python-cookbook/blob/master/src/8/...
- viklove 7y ago> You can't necessarily add properties to a base class and have all of those reflect immediately Are you talking about JS? You definitely can: class A {} class B extends A {} const b = new B(); A.prototype.test = () => 'test'; b.test(); // => 'test'