groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessio Stalla <alessiosta...@gmail.com>
Subject Re: Do closures always return a value?
Date Fri, 04 Dec 2015 10:44:40 GMT
Well, I think you could write

interface VoidClosure { void call(); }
interface FunctionClosure { Object call(); }

def someMethod(VoidClosure closure) {
    closure()
}

def someMethod(FunctionClosure closure) {
    if (closure()){
        doSomething()
    } else {
        doSomethingElse()
    }
}

Mime
View raw message