Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP 7 generator return
<?php
/**
* Generator return expressions
*/
$gen = (function() {
yield 1;
yield 2;
return 3;
})();
foreach ($gen as $val) {
echo $val, PHP_EOL;
}
echo $gen->getReturn(), 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.