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

Comments

@amelentev
Copy link
Owner

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

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

@yuemingl
Copy link

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

Implemented in eclipse-oo-plugin 0.5

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