Created
March 13, 2011 20:09
-
-
Save joseanpg/868387 to your computer and use it in GitHub Desktop.
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
//script type="application/javascript;version=1.7" | |
function GenMaker() { | |
let(j=1){for(;;) {yield (yield 'Hola '+j);j++}} | |
} | |
var gen = GenMaker(); | |
console.log(gen.next()+', the deep yield give-out Hola and give-in undefined'); | |
console.log(gen.next()+', now shallow yield return that undefined'); | |
console.log(gen.next()+', now the deep yield: Hola out, undefined in'); | |
console.log(gen.next()+', now the shallow yield: undefined'); | |
console.log(gen.next()+', now the deep yield: Hola out, undefined in'); | |
console.log(gen.next()+', now the shallow yield: undefined'); | |
console.log(gen.next()+', now the deep yield: Hola out, undefined in'); | |
console.log(gen.next()+', now the shallow yield: undefined'); | |
/** | |
Pythonic behavior | |
----------------- | |
Hola 1, the deep yield give-out Hola and give-in undefined | |
undefined, now shallow yield return that undefined | |
Hola 2, now the deep yield: Hola out, undefined in | |
undefined, now the shallow yield: undefined | |
Hola 3, now the deep yield: Hola out, undefined in | |
undefined, now the shallow yield: undefined | |
Hola 4, now the deep yield: Hola out, undefined in | |
undefined, now the shallow yield: undefined | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment