Variable reference in a Groovy GString
- by Maurits Rijk
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?