Groovy web console

subscribe to the feed Subscribe
to this
site

variadic function call

Published 3 weeks ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def someFunc(arg1, arg2){
    println arg1 + arg2
}

def funcCaller(Object... params){

    someFunc()
    (params).each { it() }
}


funcCaller({ s1="Hello", s2='World' -> someFunc(s1, s2) }, { s1="Other ", s2='Func' -> someFunc(s1, s2) })