diff --git a/src/ch03/Reader.ts b/src/ch03/Reader.ts index e38e51a..867207e 100644 --- a/src/ch03/Reader.ts +++ b/src/ch03/Reader.ts @@ -2,9 +2,11 @@ class Reader { private data: string[]; private current: number; + nextLine() { + this.current++; + } readLine() { - this.current++; return this.data[this.current] || null; } } @@ -13,7 +15,8 @@ const run = () => { const br = new Reader(); let line: string | null; - while ((line = br.readLine()) !== null) { - return line; + for (; br.readLine() !== null; br.nextLine()) { + let line = br.readLine(); + console.log(line); } };