groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Dorner <felix.dor...@gmail.com>
Subject Do closures always return a value?
Date Fri, 04 Dec 2015 10:36:32 GMT
Hi,

given that I don't need a return statement in groovy, do closures always 
return a value? Is it possible to declare
a closure to have type 'void' somehow? I would like to exploit this 
somehow like this:

def someMethod(Closure closure){

     if (closure has no return value, or is somehow defined to be 'void'){
       closure()
     } else {
             if (closure()){
                   doSomething()
             } else {
                   doSomethingElse()
             }
     }
}

Thanks,
Felix

Mime
View raw message