Created
March 15, 2017 11:31
-
-
Save augensalat/6fcb00e2ae752be36c1dbe17d28cd523 to your computer and use it in GitHub Desktop.
Look Ma, no yield!
This file contains 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
sub generiere_eins_bis_drei { | |
$i = 0; | |
return sub { | |
return if $i > 2; | |
return ++$i; | |
} | |
} | |
$generator = generiere_eins_bis_drei; | |
while ($wert = $generator->()) { | |
print "$wert\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment