★ wanayoo — archive 1999 https://github.com/amelentev/java-oo/issues/25Nouvelle recherche | Portail wanayoo
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

Reverse binary operator overload #25

Closed
amelentev opened this issue Oct 21, 2014 · 3 comments
Closed

Reverse binary operator overload #25

amelentev opened this issue Oct 21, 2014 · 3 comments
Labels

Comments

@amelentev
Copy link
Owner

@amelentev amelentev commented Oct 21, 2014

Use case - multiply double to Complex:

Complex a = new Complex(1.2, 2.3)
1.2*a

We can't add method multiply to double.

Solution:
add method Complex#multiplyRev(double)
This method will be used on second operand in cases where is no multiply method in left operand.
So: 1.2 * a will be transformed to a.multiplyRev(1.2)
This should work for every binary operator.

@amelentev
Copy link
Owner Author

@amelentev amelentev commented Dec 1, 2014

Implemented in JavaC7,8-oo-plugin 0.5, idea-oo-plugin 0.4

@yuemingl
Copy link

@yuemingl yuemingl commented Jan 2, 2015

That's really useful!

amelentev added a commit that referenced this issue Jan 22, 2015
@amelentev
Copy link
Owner Author

@amelentev amelentev commented Jan 27, 2015

Implemented in eclipse-oo-plugin 0.5

@amelentev amelentev closed this Jan 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.