<@U5M3B9M09> Generally you want Action&lt;T&gt; af...
# gradle
w
@hughg Generally you want Action<T> afaik. But which closures expect more than 1 parameter? Are they closures executed by your plugin, or by Gradle?
h
wasyl: They are closures supplied by build scripts which use the plugins, and the closures are executed by the plugins. It's a bit of an odd API, which I didn't invent but am maintaining. You register a Closure under a String name, and you can later invoke it by calling a DSL method and providing the name and a varargs
Object[]
. When the closure is actually invoked, the first argument is a helper object with some utility methods, and the second is the
Object[]
. I suppose in Groovy terms I could change the API so that
Closure
is invoked with the helper object as its delegate and the
Object[]
as its single argument, so it would fit
Action<Object[]>
. In Kotlin terms, I'd want the closure type to be
HelperClass.(Object[]) -> Unit
. But would that match `Action<Object[]>? I assume not, though I can try.
@wasyl, I ended up refactoring the code so that the
varags Object[]
is now a member of the main object, so I can use
Action<T>
.
w
@hughg thanks for info 🙂 I didn’t really have anything to add once you explained the situation, but it all makes sense