From: duerst@... Date: 2017-05-29T07:13:26+00:00 Subject: [ruby-core:81445] [Ruby trunk Feature#13606] Enumerator equality and comparison Issue #13606 has been updated by duerst (Martin D��rst). MSP-Greg (Greg L) wrote: > Could be helpful, but some `Enumerators` are not ordered. All `Enumerators` are ordered. The order is defined by the `each` method, or alternatively by the `to_a` method. Actually, I wonder if there's any difference between what the OP wants and ``` enumerator_A.to_a == enumerator_B.to_a ``` Although direct comparison for equality would be shorter, the above makes it explicit that efficiency may be low. ---------------------------------------- Feature #13606: Enumerator equality and comparison https://bugs.ruby-lang.org/issues/13606#change-65150 * 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: