Groovy 将 == 映射到 equals() 通常很方便,但是当我想按同一性进行比较时该怎么办?例如,GPathResult通过调用text()来实现equals,对于大多数内部节点来说它是空的。我正在尝试识别根节点,但通过该实现这是不可能的。如果可以通过身份进行比较的话,那是可能的。
您使用is
方法。 IE:
a.is( b )
See the docs http://groovy-lang.org/gdk.html#is%28java.lang.Object%29欲了解更多说明
edit
从groovy 3开始,您可以使用 https://docs.groovy-lang.org/latest/html/documentation/core-operators.html#_relational_operators ===
(or !==
则相反)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)