Enumeration Requirements

I'm trying to create my read-only Array data structure, and I really like the idea of ​​providing move options with the Enumerable class, but I can't find the requirements for it. In some examples that I looked, the C implementation is looking for the #each method, but it seems to me that this is not enough.

+4
source share
1 answer

From Pickaxe p. 474, as well as the main documentation :

The [mixed in Enumerable] class must provide each , which gives consecutive members of the collection. If Enumerable#max , min , sort or sort_by , the objects in the collection must also implement the meaningful <=> operator, since these methods rely on ordering between members of the collection.

+8
source

Source: https://habr.com/ru/post/1392056/


All Articles