Skip to content

Commit

Permalink
조건문에서 부수적인 동작 분리
Browse files Browse the repository at this point in the history
-
  • Loading branch information
leon-808 committed Dec 27, 2023
1 parent a8e4e99 commit 44826c2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ch03/Reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ class Reader {
private data: string[];

private current: number;
nextLine() {
this.current++;
}

readLine() {
this.current++;
return this.data[this.current] || null;
}
}
Expand All @@ -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);
}
};

0 comments on commit 44826c2

Please sign in to comment.