What is "duck type (duck typing)"?

Source: Internet
Author: User

In the computer programming world will be exposed to a knowledge point--duck typing, called "Duck type".
It has an image explanation:
"When you see a bird walking like a duck, swimming like a duck, and barking like a duck, then this bird can be called a duck." "

How to understand this sentence?

Duck, if we don't know what it means. I define: Walking, swimming, barking birds-called "ducks".

I define this "duck", which can be said to be a classification, in this category, contains the common skills (walking, swimming and barking) birds.

This "duck" belongs to "duck type". For each member of this type (not only the "duck"), its classification is based on having a common skill, that is, what will be done, and do not care about what kind of bird you are.

Another example, we define: will be fighting, love legs people-called "man", then this "guy" also belongs to "duck type".

This is duck typing.

What is "duck type (duck typing)"?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.