문제

Why does nothing happen when I make a new Class in this GroovyShell?

GroovyShell shell = new GroovyShell();

String a = "class ReportFrame$id{}; new ReportFrame$id();";
shell.evaluate(a);
도움이 되었습니까?

해결책

When you use double quotes Groovy turns your string into a GString object and tries to evaluate variables that follow a dollar sign ... change to single quotes and it should work fine ...

GroovyShell shell = new GroovyShell();
String a = 'class ReportFrame$id{}; new ReportFrame$id();'; shell.evaluate(a);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top