The caveats of duck typing in a static language.
在静态语言中使用duck类型的限制。
Of particular interest is the way it handles late binding, more commonly known today as "duck typing".
其最能引起大家兴趣的地方在于它处理“晚绑定(late binding)”的方式,现在我们通常称其为“duck typing”。
Ruby USES what is affectionately referred to as "duck typing" - if it accepts a "quack" message, it must be a duck.
Ruby使用所谓的“duck typing”——也就是说,如果它接受“鸭叫”消息,那么它一定是鸭子。
Perhaps it's a case for duck typing, the principle that it doesn't really matter what an object is, in terms of class and module, but only what it does.
可能这就是duck typing的一个例子,duck typing所代表的原则是,无论对象属于什么类或者模块,关系都不大,关键在于它做些什么。
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意味着如果一个对象对于某种类型的方法有反应,那么事实上就可以把它看作那种类型。
Affectionately known as "duck typing" (i.e., if it waddles like a duck and quacks like one, then it must be a duck!), polymorphism in Ruby is just a matter of matching method names.
Ruby中的多态性被亲切地称为“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这类特性的编程语言,通过使用更少的类型定义、减少纯粹为了支持编译器所需要的代码数,能够提高灵活性和减少重复。
The concept behind duck typing, also known as late binding, is pretty simple; if an object responds to all the methods a function is expected to call, that object can be passed to the function.
Duck typing背后的概念非常简单,就是所谓的迟绑定;如果对象具有某个函数希望调用的所有方法,就可以将这个对象传递给该函数。
With Groovy and its support for duck-typing, there is no casting involved.
有了Groovy及其对duck-typing 的支持,将不再需要强制转换。
This gives the expressiveness of duck-typing with the safety of static type-checking.
这既给予了动态类型的表达能力又保留了静态类型检查的安全。
This gives the expressiveness of duck-typing with the safety of static type-checking.
这既给予了动态类型的表达能力又保留了静态类型检查的安全。
应用推荐