Open pjustino opened 7 years ago
Can you point to the code sample / document section in here https://github.com/basarat/typescript-book/blob/master/docs/iterators.md that you want changed? Thanks! :rose:
I want to add here that in Fibonacci sequence code : Iterator does not have to iterate a finite value. The typical example is a Fibonacci sequence: let fib = new Fib(); fib.next() //{ done: false, value: 0 } fib.next() //{ done: false, value: 1 } fib.next() //{ done: false, value: 1 } fib.next() //{ done: false, value: 2 } fib.next() //{ done: false, value: 3 } fib.next() //{ done: false, value: 5 }
After I compile and run this code, I get below result every time next is called {done: true, value: null} I suppose it is because nothing is passed when Fib() is called.
Hi,
Thanks for the great work on this book, I'm loving reading it.
I just noticed that on es6 iterator example in page 50 (pdf version) there is a missing value property on next() method.
ES6 interface definition for IteratorResult requires the value to be defined :
interface IteratorResult {
done: boolean;
value: T;
}
so on the next() else case the return should be something like: return { value: null, done: true }
Hope this helps.
Regards