Yield all values from another iterator

ruby

Solution

This is probably the most idiomatic approach:

def f
  yield 'a'
  yield 'b'
end

def g(&block)
  f(&block)
  yield 'c'
  yield 'd'
end

Problem

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

Original source

Related problems