Project

General

Profile

Actions

Feature #709

closed

Enumerator#+

Added by candlerb (Brian Candler) over 15 years ago. Updated over 5 years ago.

Status:
Rejected
Target version:
[ruby-core:19681]

Description

=begin
Enumerators could be directly composable:

class Enumerator
def +(other)
Enumerator.new do |y|
each { |e| y << e }
other.each { |e| y << e }
end
end
end

if FILE == $0
a = (1..3).to_enum + (10..12).to_enum + (17..20).to_enum
a.each { |i| puts i }
end

The only problem I can see here is that this might open the floodgates to requests for more methods such as & and |, and it's not clear how those would behave. (Personally I'd go for a merge which compares the head items from each of the operands, which assumes that the operands are already in sorted order, but others may disagree)
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #15144: Enumerator#chainClosedknu (Akinori MUSHA)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0