Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP 7 generator delegation
<?php
/**
* Generator delegation
*/
function gen()
{
yield 1;
yield 2;
yield from gen2();
}
function gen2()
{
yield 3;
yield 4;
}
foreach (gen() as $val)
{
echo $val, PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.