groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Kowalczyk <>
Subject Closure does not see field when setting value
Date Tue, 08 Nov 2016 10:54:25 GMT
Today I was quite confused by behaviour of fields inside of closures.When I
read a field value it is visible, but when I try to set it, it is not set,
but a binding is set and then available for rest of the closure. This is
rather confusing, can I disable such behaviour in any way?
import groovy.transform.Field@Fieldint x = 0a {    assert x == 0    println
x    x = 1    assert x == 1    println x}assert x == 0println xdef a(Closure
c) {    c()}  ‚Äč

View this message in context:
Sent from the Groovy Users mailing list archive at
View raw message