function yielding()
{
for ($i = 0; $i < 10; $i++) {
var_dump(yield);
}
}
$y = yielding();
foreach ($y as $val) {
$y->send('foo');
}
output:
string(3) "foo"
NULL
string(3) "foo"
NULL
string(3) "foo"
NULL
string(3) "foo"
NULL
string(3) "foo"
i expected the output to be: 10 time string(3) "foo"
, but instead the output is one NULL
and one string(3) "foo"
(9 times). why is it?
does generator->send() skip one iteratoration?