作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我一直在尝试设计我的只读 Array 数据结构,我非常喜欢为 Enumerable 类提供遍历选项的想法,但我找不到它的要求。在我看过的一些例子中,C 实现寻找 #each
方法,但在我看来这还不够。
最佳答案
来自 Pickaxe p. 474 也来自 the core documentation :
The class [mixing in Enumerable] must provide a method
each
, which yields successive members of the collection. IfEnumerable#max
,min
,sort
, orsort_by
is used, the objects in the collection must also implement a meaningful<=>
operator, because these methods rely on an ordering between members of a collection.
关于ruby - 包括可枚举的要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8943040/
我是一名优秀的程序员,十分优秀!