I have a simple Groovy script like this:
class Main {
static void main(String... args) {
args.each {
println ${it}
}
}
}
I cannot figure out how to pass command line arguments to it. I'm on Windows and run the script as:
Groovy myscript.groovy "arg1" "arg2"
And it results in error:
Caught: groovy.lang.MissingMethodException: No signature of method: Main$_main_closure1.$() is applicable for argument types: (Main$_main_closure1$_closure2) values: [Main$_main_closure1$_closure2@68b32e3e] Possible solutions: is(java.lang.Object), is(java.lang.Object), any(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;) groovy.lang.MissingMethodException: No signature of method: Main$_main_closure1.$() is applicable for argument types: (Main$_main_closure1$_closure2) values: [Main$_main_closure1$_closure2@68b32e3e] Possible solutions: is(java.lang.Object), is(java.lang.Object), any(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;) at Main$_main_closure1.doCall(hash_text.groovy:10) at Main.main(hash_text.groovy:9)
you have just a syntax error. instead of
println ${it}
use
println it
or
println "${it}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With