Skip to content

Reverse binary operator overload #25

Closed
@amelentev

Description

@amelentev

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.

Activity

amelentev

amelentev commented on Dec 1, 2014

@amelentev
OwnerAuthor

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

yuemingl

yuemingl commented on Jan 2, 2015

@yuemingl

That's really useful!

amelentev

amelentev commented on Jan 27, 2015

@amelentev
OwnerAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @amelentev@yuemingl

        Issue actions

          Reverse binary operator overload · Issue #25 · amelentev/java-oo