Skip to content

Instantly share code, notes, and snippets.

@ThijsFeryn
Created November 30, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThijsFeryn/e4b706d415f3dd8dab48 to your computer and use it in GitHub Desktop.
Save ThijsFeryn/e4b706d415f3dd8dab48 to your computer and use it in GitHub Desktop.
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