Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dollar side effects #2

Merged
merged 4 commits into from
Sep 28, 2022
Merged

Conversation

kaiosilveira
Copy link
Owner

@kaiosilveira kaiosilveira commented Sep 28, 2022

After committing a lot of sins in order to make the first test pass, we've introduce a subtle side effect: a dollar object can't be reliably multiplied many times, this happens because we're updating the amount instance variable, thus keeping the updated value as part of the current object. To solve this problem, a new Dollar object is now being returned as a result of Dollar.times.

Our current tasklist is:

  • $5 + 10CHF = $10 if rate is 2:1 🎯
  • $5 * 2 = $10
  • Make "amount" private
  • Dollar side-effects?
  • Money rounding?

Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private
- Dollar side-effects? 👈🏼
- Money rounding?
Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private
- Dollar side-effects? 👈🏼
- Money rounding?
Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private
- Dollar side-effects? 👈🏼
- Money rounding?
Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private
- Dollar side-effects? ✅
- Money rounding?
@kaiosilveira kaiosilveira merged commit 5e2c527 into main Sep 28, 2022
@kaiosilveira kaiosilveira deleted the chapter2/fixing-dollar-side-effects branch September 28, 2022 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant