Switch language
zh
Switch theme
Light

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

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

🍀