I want to pass parameter in function but it giving...
# android
v
I want to pass parameter in function but it giving error  This syntax is reserved for future use; to call a reference, enclose it in parentheses: (foo::bar)(args). Also i want to make a genric runFunction which can take any parameter i.e. Int, String etc. In this example code i am sending sumInt(2) to runFunction also i want to send concatenateString("John"). Anyone Know how to achieve this.
z
It looks like you’re trying to curry the
sumInt
function, which kotlin doesn’t support.
v
Copy code
fun main(vararg args: String) {
    runFunction { sumInt(2) }
    runFunction { concatenateString("John") }
}

fun <T: Any> runFunction(action: () -> (T)) {
    println(action())
}

private fun sumInt(a: Int): Int {
    return a + 2
}

private fun concatenateString(a: String): String {
    return "$a welcome"
}
i got it from this 👆 @Zach Klippenstein (he/him) [MOD] thanks for your time 😁