You can use the property accessor operator @
like so:
this.@bar[ it ] = it
Domanda
I have something like the following groovy class :
class Foo {
private Map<String,String> bar = [:]
Map<String, String> getBar() {
return bar.asImmutable()
}
def doSomething(List<String> argValues){
argValues.each {
bar[it] = it
}
}
}
The doSomething method will fail, it seem, in the each closure, the bar property is use trough accessor, not the field. So it's immutable.
The question is "how can i use the field (not the accessor) within the closure ?
Thanks.
Soluzione
You can use the property accessor operator @
like so:
this.@bar[ it ] = it