Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
How to implement the suspend keyword to modify higher-order functions in kotlin poet

I want to modify higher-order functions with the ”suspend“ keyword. The following is what I want:

public fun login(io: suspend () -> ResLogin): Unit {}

I tried to use:

val lambdaTypeName = LambdaTypeName.get(returnType = responseBean)

But get the following code:

public fun login(io: () -> ResLogin): Unit {}

I don’t know how to start, and the official website API has been checked for a long time and I haven’t found a similar answer. I hope the boss will give instructions!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The answer has been found, it can be solved by LambdaTypeName.copy(suspending = true), the specific code is as follows:

val lambdaTypeName = LambdaTypeName.get(returnType = responseBean)
                FunSpec.builder(it.methodName).addParameter(ParameterSpec.builder("io",lambdaTypeName.copy(suspending = true)).build())
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda