- if S is a subtype of T, then objects of type T may be replaced with objects of type S
- If class Man is inherited from class Human, then objects of class Human may be replaced with objects of class Man
- if it looks like a duck and quacks like a duck, it's a duck
Explanation:
We have class Human and method talk returns string
We create inherit class HomoHabilis - and user polymorphism - implement new talk method - and return other string.
So if the talk method doesn't return string, and return hash or something else - We broke this principles. Don't do it!
http://rubyblog.pro/
Comments
Post a Comment