https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
j

jean

08/16/2022, 6:19 AM
The kotlinpoet channel is archived so I assumed one should use this channel to ask a questions? I’m trying to implement a
fun interface
but the generated code is using a`:` instead of a
=
like so :
Copy code
public fun <AsyncDataType, LoadEvent> loadAsyncData(
    key: TransitionKey,
    loader: (LoadEvent) -> AsyncDataType
): ReusableTransition<LoadEvent> { updater, event ->
    ...
}
I use the following code to generate it
Copy code
FunSpec.builder("loadAsyncData")
    .addTypeVariable(asyncDataType)
    .addTypeVariable(loadEvent)
    .addParameter("key", TransitionKeyGenerator.className)
    .addParameter("loader", loader)
    .returns(reusableTransition)
    .addCode(
        CodeBlock.builder()
            .add(...)
            .build()
    ).build()
g

Grégory Lureau

08/16/2022, 9:13 AM
afair,
returns()
is for the return type. You can return from the
addCode