groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Kowalczyk <kowalczyk.krzysz...@gmail.com>
Subject Closure does not see field when setting value
Date Tue, 08 Nov 2016 10:54:25 GMT
Hi,
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: http://groovy.329449.n5.nabble.com/Closure-does-not-see-field-when-setting-value-tp5736534.html
Sent from the Groovy Users mailing list archive at Nabble.com.
Mime
View raw message