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

Add, Subtract, Multiply Many #117

Merged
merged 6 commits into from
Jul 29, 2024
Merged

Add, Subtract, Multiply Many #117

merged 6 commits into from
Jul 29, 2024

Conversation

AyoobMH
Copy link
Contributor

@AyoobMH AyoobMH commented Aug 9, 2022

  • Please check if the PR fulfills these requirements
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Feature

  • What is the current behavior? (You can also link to an open issue here)
    Addition, subtraction, and multiplication can only be done with single values.

  • What is the new behavior (if this is a feature change)?
    Addition, subtraction, and multiplication using many values.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    NO

  • Other information:

  • Fixes Add/Subtract multiple amounts together #74

  • Credit to @SepehrAsh for opening Add Multiple & Subtract Multiple Functions Added , Some Test Added , … #78 ,but it got closed.

@Rhymond
Copy link
Owner

Rhymond commented Aug 10, 2022

Hi @AyoobMH

Thanks for the PR! I was just thinking, maybe we can update original methods to accept variadic parameters instead?

func (m *Money) Add(om ...*Money) (*Money, error)

In that way the functionality to add multiple would exists and it would not introduce any breaking changes. Of course, I would expect to do a sanity check if len(om) != 0 and return error before applying operation.

What do you think?

@AyoobMH
Copy link
Contributor Author

AyoobMH commented Aug 10, 2022

Hi @Rhymond, thanks for your efforts.

I think updating original methods to have variadic parameters is even better, it wouldn't introduce any redundant code. Are you thinking of updating only Add, Subtract, Multiply? I would be happy to open another PR for that.

@Rhymond
Copy link
Owner

Rhymond commented Aug 10, 2022

Hi @Rhymond, thanks for your efforts.

I think updating original methods to have variadic parameters is even better, it wouldn't introduce any redundant code. Are you thinking of updating only Add, Subtract, Multiply? I would be happy to open another PR for that.

Exactly! Yes Add, Subtract and Multiply. Appreciate your time 🙏

@AyoobMH
Copy link
Contributor Author

AyoobMH commented Aug 10, 2022

Hi @Rhymond

I have modified the PR and added variadic parameters. For checking parameters, I have used panic instead of an error, I believe not passing any parameter is considered a bad use of the package and should not happen during runtime. What do you think?

money.go Outdated Show resolved Hide resolved
money.go Outdated Show resolved Hide resolved
money.go Outdated Show resolved Hide resolved
money.go Outdated Show resolved Hide resolved
money.go Show resolved Hide resolved
@AyoobMH
Copy link
Contributor Author

AyoobMH commented Aug 19, 2022

@totemcaf Thanks for the review, the requested changes were made!

@AyoobMH AyoobMH requested a review from totemcaf August 19, 2022 16:30
@AyoobMH
Copy link
Contributor Author

AyoobMH commented Nov 14, 2022

Hi @Rhymond @totemcaf , this PR is ready for review, would appreciate your review, thanks in advance!

@AyoobMH
Copy link
Contributor Author

AyoobMH commented May 16, 2024

Hi @Rhymond, any updated for this PR, thanks in advance!

Copy link
Owner

@Rhymond Rhymond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for late response, LGTM

@Rhymond Rhymond merged commit f9d20a6 into Rhymond:master Jul 29, 2024
4 checks passed
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.

Add/Subtract multiple amounts together
3 participants