Skip to content

Commit d47f5c8

Browse files
committed
Feat: fix to stack file; threw an explicit error condition
1 parent 235c36f commit d47f5c8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lesson_12/structs_ts/src/stack.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ export class Stack {
2121
return val;
2222
}
2323

24-
peek(): number | null {
25-
return this.isEmpty() ? null : this.top?.val;
24+
peek(): number {
25+
if (this.isEmpty()) {
26+
/* empty */
27+
}
28+
return this.top!.val;
2629
}
2730

2831
isEmpty(): boolean {

0 commit comments

Comments
 (0)