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

Plus operator #49

Closed
DejanMilicic opened this issue May 27, 2017 · 1 comment
Closed

Plus operator #49

DejanMilicic opened this issue May 27, 2017 · 1 comment

Comments

@DejanMilicic
Copy link

If I try something like this

Money money = new Money(10, "GBP");
list[gbpAnountNdx] += 10;

I do not end up with 20 GBP, I end up with the exception.
Reson? My local culture is USA, so plus operator first created sctruct Money using "USD" and then tried to perform addition, which caused exception since I attempted to add two different currencies.

Can we introduce addition operator override that would treat numbers in a proper way - look at currency, create new Money with that currency and then call existing override that sums up two Money structs?

@RemyDuijkeren
Copy link
Owner

Sounds like a good proposal. A user is probably expecting that the same currency in this case, so optimize for would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants