In the context of programming languages, duck typing means that if an object responds to the methods of a type, then for all practical purposes, you can treat it like that type.
在编程语言的上下文中,duck typing意味着如果一个对象对于某种类型的方法有反应,那么事实上就可以把它看作那种类型。
Programming languages with features like duck typing can improve flexibility and reduce repetition by forcing fewer type definitions and reducing code needed purely to support a compiler.
具备诸如duck typing这类特性的编程语言,通过使用更少的类型定义、减少纯粹为了支持编译器所需要的代码数,能够提高灵活性和减少重复。
Structural Subtyping (duck typing) using type inference and anonymous types.
使用类型引用和匿名类型的结构子类型转化(动态类型)。
应用推荐