How to yield empty generator?
问题 I have a method which takes a generator plus some additional parameters and yields a new generator: function merge(\Generator $carry, array $additional) { foreach ( $carry as $item ) { yield $item; } foreach ( $additional as $item ) { yield $item; } } The usual use case for this function is similar to this: function source() { for ( $i = 0; $i < 3; $i++ ) { yield $i; } } foreach ( merge(source(), [4, 5]) as $item ) { var_dump($item); } But the problem is that sometimes I need to pass empty