Lazy Line · Level 3 of 8

Labels on the items

One generator yields key => value pairs; another yields plain values.

<?phpfunction prices() {    yield 'tea' => 2;    yield 'soup' => 5;}foreach (prices() as $name => $price) {    echo "$name costs $price" . PHP_EOL;}function plain() {    yield 'a';    yield 'b';}foreach (plain() as $k => $v) {    echo "$k => $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…