Duck Typing

Back to Polymorphism

“If it walks like a duck and quacks like a duck, it’s a duck.” Objects are typed by their behavior (methods and properties) rather than their class hierarchy. Common in dynamic languages like Python and Ruby, and structural typing in Go and TypeScript.

property polymorphism duck-typing