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 Thu, 10 Nov 2016 09:36:31 GMT
> so how do you define a variable and use that variable in a method in a
script?

A variable that is accessible to a method sound a lot like a field to me.
Thus my usage of @Field. It would be nice if it would be imported in all
scripts by default. If not for the binding it would also act exactly the
same with or without compile static, which is another plus side. Of course
I would still want to be able to set binding for script context in general
and be able to read them. That said, if I want to export a binding to
external world I would prefer some special way of doing that.

In Gradle to create a "global" variable one use ext.x = 1
In Beaker notebook to create a variable that is shared across sections one
do beaker.x = 1

Regards,
Krzysztof

On 10 November 2016 at 00:42, Jochen Theodorou [via Groovy] <
ml-node+s329449n5736616h36@n5.nabble.com> wrote:

> On 09.11.2016 22:53, Krzysztof Kowalczyk wrote:
> > Thanks,
> >
> > I understand why it is happening. I don't understand why someone would
> > want the binding to be created on the fly in such way. It is
> > counterintuitive for me. It has serious consequences and I don't see a
> > use case where I would want such behaviour (for the "set").
>
> so how do you define a variable and use that variable in a method in a
> script?
>
> 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-tp5736534p5736616.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-tp5736534p5736622.html
Sent from the Groovy Users mailing list archive at Nabble.com.
Mime
View raw message