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

288
Vistas
How do you define an array of funs(functions) in Kotlin?

How do you define an array of funs(functions) in Kotlin?

This is my assumption of how it would be done...

this.funs = arrayOf : Unit(
    this::openCamera,
    this::sendSMS,
    this::makeCall
        )

How would I invoke each array item as a function at runtime? Would simply specifying 'funs' in place of either openCamera(), sendSMS(), and MakeCall() in a forEach() loop work?

or.. is this the way that I would invoke each function:

val function = getFunction(funs)
function() 
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you had some functions defined as

fun one()   { print("ONE") }
fun two()   { print("TWO") }
fun three() { print("THREE") }

Then you can create an array of these as

fun someFun(){
    val arrayOfFunctions: Array<() -> Unit> = arrayOf(::one, ::two, ::three)
    arrayOfFunctions.forEach { function ->
       function()
    }
}
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