Groovy Closures Recursive

Ola
Pessoal, esse final de semana dei uma estuada em Groovy.
Na parte de Closures tentei realizar um fatorial utilizando recursividade , mas a minha surpresa deu um erro na tentativa de chamar ele proprio mas precisamente na chamada this.call(num-1) pela Exception ele nao reconhece o metodo call com argumento Integer
Estranho nao?

def factorial = { num ->
				if (num == 0)
					return 1
				else
					return num * this.call(num -1)	
		}
		
		println "Fatorial de 5 eh ${factorial(5)}"

Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: static br.com.groovy.HelloWorld.call() is applicable for argument types: (java.lang.Integer) values: {4}
	at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1127)
	at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1113)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeStaticMethod(InvokerHelper.java:796)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeStaticMethodN(ScriptBytecodeAdapter.java:212)
	at br.com.groovy.HelloWorld$_main_closure2.doCall(HelloWorld.groovy:22)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:95)
	at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:599)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:252)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)
	at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:773)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeClosure(ScriptBytecodeAdapter.java:598)
	at br.com.groovy.HelloWorld.main(HelloWorld.groovy:25)

Problema resolvido, parece this.call só funciona com a versão <=1.0
Ao invés de this.call chamar apenas call ou de outra forma:

def factorial = {}
		factorial = { num -&gt;
				if (num == 0)
					return 1
				else
					return num * factorial(num -1)	
		}
		
		println &quot;Fatorial de 5 eh ${factorial(5)}&quot;

É aconselhável utilizar a segunda forma.

Usa um YCombinator que vc resolve esse problema.

Ola
Louds,
O que seria este YCombinator?
Procurei no google relacionado com groovy mas não achei qse nda :frowning: