Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Concept

Duck Typing

Foundational Concept

Duck typing is an application of the duck test, if it walks like a duck and it quacks like a duck then it must be a duck, to determine whether an object can be used for a particular purpose. The cited article contrasts it with nominative typing, in which an object is of a given type if it is declared as such or if the association is inferred through mechanisms such as object inheritance, whereas with duck typing an object is of a given type if it has all the methods and properties required by that type. It says duck typing may be viewed as a usage-based structural equivalence between a given object and the requirements of a type. Languages the atlas records as duck typed are grouped under this entry.

Facts
Core Principle
Do not check an object's type to see whether it has the right interface; simply call or use the method or attribute. 1
Duck Typing
Filter Results2 entries
Connections

Typing Discipline Of Language

Sources
1. Python glossary
Entry duck-typing
Quote, Entry duck-typing
A programming style which does not look at an object’s type to determine if it has the right interface; instead, the method or attribute is simply called or used
View the Source
Duck typing (Wikipedia)
  • Lead section
    In computer programming, duck typing is an application of the duck test-"If it walks like a duck and it quacks like a duck, then it must be a duck"-to determine whether an object can be used for a particular purpose.
  • In Group: Typing Disciplines, Lead
    In computer programming, duck typing is an application of the duck test, "If it walks like a duck and it quacks like a duck, then it must be a duck", to determine whether an object can be used for a particular purpose.
View the Source
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.