groovy:访问class.value而无需致电getValue()
我找不到有关此的信息。 我写了一个数据类型类,并想返回值属性,因为默认值
MyInteger{
Integer value
MyInteger(Integer iv)
{
this.value = iv
}
}
如何在不调用getValue()的情况下获取值?
MyInteger i = new MyInteger(5)
print i.value //works
print i.getValue() //works
print i //this is what I want to achieve
Integer realInt = i //or more specific this
标准整数能够做到这一点,但是如何? 感谢您的提示!
I can't find information about this.
I wrote a DataType class and want to return the value property as the default
MyInteger{
Integer value
MyInteger(Integer iv)
{
this.value = iv
}
}
How can I get the value without calling getValue() ?
MyInteger i = new MyInteger(5)
print i.value //works
print i.getValue() //works
print i //this is what I want to achieve
Integer realInt = i //or more specific this
The Standard Integer is capable of that, but how?
Thanks for any hint!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道您的意图是什么,但是可以像这样制作和使用“新整数”:
Not sure what was your intent, but a "new integer" can be crafted and used like so: