Duck Type 鸭子类型

Duck Typing is a [type system] used in dynamic languages. For example, Python, Perl, Ruby, PHP, Javascript, etc. where the type or the class of an object is less important than the method it defines. Using Duck Typing, we do not check types at all. Instead, we check for the presence of a given method or attribute.

reference: geeksforgeeks

按上述来说, 鸭子类型是动态语言的特性, 在动态语言中, 类型并不重要, 重要的是类型(实例)的方法

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容