Issue #13606 has been updated by glebm (Gleb Mazovetskiy).


duerst (Martin Drst) wrote:
> Sounds interesting in theory, but do you have actual use cases? And do you think that the potential inefficiency is worth it?

The use cases are the same as for comparing `Array`s.
The potential inefficiency is not a problem because if you need to compare `Enumerator`s by `object_id` you can do it using `equal?`. If the `object_id`s are the same, both the current and the proposed comparisons take constant time.

----------------------------------------
Feature #13606: Enumerator equality and comparison
https://bugs.ruby-lang.org/issues/13606#change-65142

* Author: glebm (Gleb Mazovetskiy)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
In Ruby, most objects are compared by value. What do you think about `Enumerator`s following the same pattern? I think this would greatly increase the expressiveness of Ruby.

Proposal:

Two `Enumerator`s should be considered equal (`==`) if they yield the same number of elements and these elements are equal (`==`).
If both of the `Enumerator`s are infinite, the equality operator never terminates.
`<=>` should be handled similarly.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>