Last active
December 22, 2015 10:49
-
-
Save niwinz/6461676 to your computer and use it in GitHub Desktop.
Why I cannot bind some class to one variable on groovy?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[3/5.0.2]niwi@localhost:~/Downloads/groovy-2.2.0-beta-2> ./bin/groovysh | |
Groovy Shell (2.2.0-beta-2, JVM: 1.7.0_40) | |
Type 'help' or '\h' for help. | |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
groovy:000> class Foo {} | |
===> true | |
groovy:000> instance1 = new Foo() | |
===> Foo@6f24bcc6 | |
groovy:000> cls = Foo | |
===> class Foo | |
groovy:000> cls | |
===> class Foo | |
groovy:000> new cls() | |
ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException: | |
startup failed: | |
groovysh_evaluate: 2: unable to resolve class cls | |
@ line 2, column 1. | |
new cls() | |
^ | |
1 error | |
at java_lang_Runnable$run.call (Unknown Source) |
No, it's not a bug, it's just not supported.
There were some historical reasons for that at the time we made that design decision, but the details escape me now.
Thanks for comments. But would be nice to use new in these cases too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think is a bug