Lazy Line · Level 6 of 8

A machine inside a machine

An outer generator that hands over to an inner one with yield from.

<?phpfunction inner() {    yield 'b';    yield 'c';    return 'inner done';}function outer() {    yield 'a';    $result = yield from inner();    echo $result . PHP_EOL;    yield 'd';}foreach (outer() as $v) {    echo $v . PHP_EOL;}

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…
  4. 4…
  5. 5…