groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Kowalczyk <kowalczyk.krzysz...@gmail.com>
Subject Re: Closure does not see field when setting value
Date Tue, 08 Nov 2016 17:05:23 GMT
Is there a public version of "long list of things to be changed"?

On 8 November 2016 at 16:48, Jochen Theodorou [via Groovy] <
ml-node+s329449n5736566h86@n5.nabble.com> wrote:

>
>
> On 08.11.2016 14:47, Krzysztof Kowalczyk wrote:
>
> > Jochen Theodorou wrote
> >> there we access the field only directly if [...]  an explicit this is
> >> used.
> >
> > So should prefixing it with "this" should change the behaviour?
> > It does not:
> >
> > <pre>
> > ‚Äčimport groovy.transform.Field
> >
> > @Field
> > int x = 0
> >
> > a {
> >     assert this.x == 0
> >     this.x = 1
> >     assert this.x == 1
> > }
> >
> > assert x == 0
> >
> > def a(Closure c) {
> >     c()
> > }  ‚Äč
> > </pre>
>
> ah right, sorry, this is on a long list of things to be change, but yes,
> it does not solve the problem. You can solve it by using this.@x, since
> that forces field access, but I think you may still get into trouble
> with subclasses...
>
> bye Jochen
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://groovy.329449.n5.nabble.com/Closure-does-not-
> see-field-when-setting-value-tp5736534p5736566.html
> To unsubscribe from Closure does not see field when setting value, click
> here
> <http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5736534&code=a293YWxjenlrLmtyenlzenRvZkBnbWFpbC5jb218NTczNjUzNHwtNjY3ODI1Mzg4>
> .
> NAML
> <http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://groovy.329449.n5.nabble.com/Closure-does-not-see-field-when-setting-value-tp5736534p5736567.html
Sent from the Groovy Users mailing list archive at Nabble.com.
Mime
View raw message