Skip to content

Commit

Permalink
♻️ 【第3章 三角測量】null との等値性比較の実装
Browse files Browse the repository at this point in the history
  • Loading branch information
dodonki1223 committed Dec 7, 2021
1 parent c5788d5 commit 2b76bae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
- [ ] amount を private にする
- [x] Dollar の副作用どうする?
- [ ] Money の丸め処理どうする?
- [ ] nullとの等価性比較
- [x] nullとの等価性比較
- [x] equals()メソッドの実装
6 changes: 5 additions & 1 deletion src/dollar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export class Dollar {
return new Dollar(this.amount * multiplier)
}

equals(dollar: Dollar) {
equals(dollar: Dollar | null) {
if (dollar === null) {
return false;
}

return this.amount === dollar.amount
}
}

0 comments on commit 2b76bae

Please sign in to comment.