Skip to content

Commit

Permalink
♻️ 【第2章 明白な実装】Dollarの副作用の解消をする①
Browse files Browse the repository at this point in the history
コンストラクタで渡されたものを別の変数に入れて対応する
  • Loading branch information
dodonki1223 committed Dec 7, 2021
1 parent 2a65e86 commit 119ae23
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dollar.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
export class Dollar {
private tmpAmount: number

constructor(public amount: number) {
this.tmpAmount = amount
this.amount = amount
}

times(multiplier: number) {
this.amount *= multiplier
this.amount = this.tmpAmount * multiplier
}
}

0 comments on commit 119ae23

Please sign in to comment.