Issue #13606 has been updated by shevegen (Robert A. Heiler).


I am not even sure that I understand the proposal.

If I understood it correctly then two enumerable objects (did I get this part right)
should return true if they behave/return the same? I think I can see it being 
related to duck typing... but they are not entirely the same are they? Different
object id for most objects for example. But it also may be that I did not fully
understand the proposal yet.

What would the speed penalty be if one exists? I guess the latter one could be
handled by some "behavioural switch" for people who need the behaviour
desscribed in the proposal, so a use-case example would be helpful.

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

* 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>