Java 3


SUBMITTED BY: assassin413

DATE: Oct. 7, 2016, 2:07 p.m.

FORMAT: Text only

SIZE: 271 Bytes

HITS: 703

  1. function* idMaker(){
  2. var index = 0;
  3. while(index < 3)
  4. yield index++;
  5. }
  6. var gen = idMaker();
  7. console.log(gen.next().value); // 0
  8. console.log(gen.next().value); // 1
  9. console.log(gen.next().value); // 2
  10. console.log(gen.next().value); // undefined
  11. // ...

comments powered by Disqus