Created
November 8, 2018 08:35
-
-
Save Tocacar/4407c585bc71e56847f2aa336d4bf9db to your computer and use it in GitHub Desktop.
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
function count_to_ten() { | |
yield 1; | |
yield 2; | |
yield from [3, 4]; | |
yield from new ArrayIterator([5, 6]); | |
yield from seven_eight(); | |
yield 9; | |
yield 10; | |
} | |
function seven_eight() { | |
yield 7; | |
yield from eight(); | |
} | |
function eight() { | |
yield 8; | |
} | |
foreach (count_to_ten() as $num) { | |
echo "$num "; | |
} | |
// This yields 1 2 3 4 5 6 7 8 9 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment