0

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?

4

2 回答 2

2

您不能在 Java 中重新定义运算符。你可以在 Xtend 中。当您调用覆盖运算符时,
Xtend 编译器将生成Java 代码。e1.operator_plus(e2)+

于 2013-11-13T11:52:50.583 回答
1

创建或复制 Xtend 文件到 Java 项目中,然后打开它,这将在项目上安装 Xtend 构建器。现在,您将在第一行代码上有一个问题标记,使用 Ctrl+1 快速修复它,这会将必要的 Xtend 库添加到类路径中。就这样。

来源: Xtend 安装说明的入门部分。

注意:正如@rzymek所说,您只能在 Xtend 中使用覆盖运算符,Java 只会看到方法operator_plus

于 2013-11-13T11:36:17.137 回答