Does Ruby provide any mechanism to allow an iterator to yield
all values from another iterator? (or "subiterator", I'm not sure what the proper name is). Similar to Python3.3+'s yield from
def f
yield 'a'
yield 'b'
end
def g
# yield everything from f
yield 'c'
yield 'd'
end
This is probably the most idiomatic approach:
def f
yield 'a'
yield 'b'
end
def g(&block)
f(&block)
yield 'c'
yield 'd'
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With