Variable reference in a Groovy GString
Posted
by Maurits Rijk
on Stack Overflow
See other posts from Stack Overflow
or by Maurits Rijk
Published on 2010-03-29T08:54:34Z
Indexed on
2010/03/29
9:03 UTC
Read the original article
Hit count: 223
groovy
|compiler-errors
From the book "Groovy and Grails recipes" I'm using the following code snippet:
String HelloLanguage = "def hello(language) {return \"Hello $language\"}"
However, I get a compiler error "You attempted to reference a variable in the binding or an instance variable from a static context." because language can't be bound. What is wrong?
© Stack Overflow or respective owner