Created
November 30, 2015 14:16
-
-
Save ThijsFeryn/6ad19bdc5166b49ffe0d to your computer and use it in GitHub Desktop.
PHP 7 generator return
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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