ruby – 包括Enumerable的要求

ruby – 包括Enumerable的要求,第1张

概述我一直在尝试设计我的只读数组数据结构,我真的很喜欢用Enumerable类提供遍历选项,但我找不到它的要求.在我看过的一些例子中,C实现寻找#each方法,但在我看来它还不够. 从 Pickaxe p. 474以及 the core documentation: The class [mixing in Enumerable] must provide a method each, which y 我一直在尝试设计我的只读数组数据结构,我真的很喜欢用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. If Enumerable#max,
min,sort,or sort_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 – 包括Enumerable的要求全部内容,希望文章能够帮你解决ruby – 包括Enumerable的要求所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1286683.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-09
下一篇2022-06-09

发表评论

登录后才能评论

评论列表(0条)

    保存