20 Jul 08:28
[groovy-user] Recursivity bug with closure?
From: Pierre Thibault <pthibault33@...>
Subject: [groovy-user] Recursivity bug with closure?
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-20 06:32:15 GMT
Subject: [groovy-user] Recursivity bug with closure?
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-07-20 06:32:15 GMT
Hello,
I think that I found a recursivity bug with closure. This code does not work:
def factoriel = { int v ->
if (v == 0) {
return 1
} else {
return v*this.factoriel(v-1)
}
}
println factoriel(5)
But this work well:
def factoriel(int v) {
if (v == 0) {
return 1
} else {
return v*this.factoriel(v-1)
}
}
println factoriel(5)
I've tried with Groovy 1.5.5 and 1.5.6.
Any idea?
Pierre
I think that I found a recursivity bug with closure. This code does not work:
def factoriel = { int v ->
if (v == 0) {
return 1
} else {
return v*this.factoriel(v-1)
}
}
println factoriel(5)
But this work well:
def factoriel(int v) {
if (v == 0) {
return 1
} else {
return v*this.factoriel(v-1)
}
}
println factoriel(5)
I've tried with Groovy 1.5.5 and 1.5.6.
Any idea?
Pierre
RSS Feed