java - Groovy : excute a class.method in a String -


i have groovy class here:

plus.groovy def add = { int x, int y ->   return x+y } 

how use in groovy or in java 'plus.add(5,6)' , result 11

thanks

i'm not sure you're trying achieve here, asking how use method groovy? given following class definition

class plus {     def add(def x, def y) {         return x + y;     } }  // assert test assert 4 == new plus().add(2, 2) 

Comments