【问题标题】:Xtend operator overloading on existing class现有类上的 Xtend 运算符重载
【发布时间】:2014-03-01 14:05:55
【问题描述】:

我尝试使用 Xtend 重载现有外部类的运算符,但它不起作用。我不能在类源中写,比如 BigIntegerExtension。我该怎么做?

回答

答案很简单。我们可以使用operator overload 覆盖我们想要的任何运算符。

// IntVar = IntVar
def static operator_equals(IntVar a, IntVar b) {
    return IntConstraintFactory.arithm(a, "=", b)
}

【问题讨论】:

  • Xtend,你的意思是extend吗?
  • @RohitJain eclipse.org/xtend
  • 是的,我的意思是link 谢谢@RohitJain。
  • 你应该把你的答案变成一个真实的答案。

标签: java operator-overloading xtend


【解决方案1】:

答案很简单。我们可以通过运算符重载覆盖任何我们想要的运算符。

// IntVar = IntVar
def static operator_equals(IntVar a, IntVar b) {
    return IntConstraintFactory.arithm(a, "=", b)
}

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多