Reputation: 2066
I find one use case today with groovy like this:
manager.build.@result = hudson.model.Result.SUCCESS
It adds a @ before the attribute, what is the purpose for that?
I test it in my local place, and I don't find big diff between we have @ and without @.
My example is as follows:
class Person {
private String hello;
}
def person = new Person()
person.hello = "hello world"
println person.@hello
Br,
Tim
Upvotes: 1
Views: 36
Reputation: 84756
It's used to access the field directly (without getter), see:
class Person {
private String hello
public String getHello() {
"lol $hello"
}
}
def person = new Person()
person.hello = "hello world"
assert person.@hello == 'hello world'
assert person.hello == 'lol hello world'
Upvotes: 2