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/6ad19bdc5166b49ffe0d to your computer and use it in GitHub Desktop.
Save ThijsFeryn/6ad19bdc5166b49ffe0d to your computer and use it in GitHub Desktop.
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