Note that defining function directly cannot work, such as “def getName() {return “Max”;}”. Groovy reports the following error:
1 2 3 4 5 6
$ groovy main.groovy Caught: groovy.lang.MissingMethodException: No signature of method: main.getName() is applicable for argument types: () values: [] Possible solutions: getAt(java.lang.String), getClass() groovy.lang.MissingMethodException: No signature of method: main.getName() is applicable for argument types: () values: [] Possible solutions: getAt(java.lang.String), getClass() at main.run(main.groovy:2)