groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Laforge <glafo...@gmail.com>
Subject Re: A strange script
Date Fri, 20 Jan 2017 08:49:25 GMT
Hi Yang,

Interpolated values in a GString that are closures are executed.
Have a look at the documentation which shows some examples of this:
http://groovy-lang.org/syntax.html#_special_case_of_interpolating_closure_expressions

Guillaume


On Fri, Jan 20, 2017 at 8:22 AM, Yang Yang <reliveyy@gmail.com> wrote:

> *Script:*
> a = {x -> println x}
> a("a${a}")
>
> *Output:*
> a
> a
>
> Why?
>



-- 
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>

Mime
View raw message