Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requirements for including Enumerable

I've been trying to design my read only Array data structure and I really like the idea of providing traversing options with Enumerable class, but I cannot find requirements of it. In some examples that I've looked, the C implementation looks for #each method, but it seems to me that it can't be enough.

like image 261
farnoy Avatar asked Feb 22 '23 18:02

farnoy


1 Answers

From Pickaxe p. 474 and also from 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.

like image 175
Wayne Conrad Avatar answered Mar 08 '23 04:03

Wayne Conrad