Question

I know that its possible to redefine operands with Xtend. My question is, can I redefine an operand using Xtend code and then import this source code into Java project to use it?

For example I would redefine the operand + with Xtend, than I import this source into my Java project and use the redefined operand. Is it possible?

Was it helpful?

Solution 2

Create or copy an Xtend file into a Java project, then just open it, this will install the Xtend builder on the project. Now, you will have a problem marker on the first line of code, quick fix it with Ctrl+1, this will add the necessary Xtend libs to the classpath. That's all.

Source: the Getting Started section of Xtend's installation instructions.

Note: as @rzymek says, you will be able to use the overriden operator only in Xtend, Java will only see the method operator_plus.

OTHER TIPS

You can't redefine operators in Java. You can in Xtend.
Xtend compiler will generate e1.operator_plus(e2) Java code, when you're calling an overriden + operator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top