Emil Kantis
08/23/2023, 1:48 PMEmil Kantis
08/23/2023, 1:48 PMfun curry(x: Int): suspend (Int) -> Unit = {
suspendPrint(x + it)
}
Emil Kantis
08/23/2023, 1:52 PMYoussef Shoaib [MOD]
08/23/2023, 2:10 PM{ f(it) }
Emil Kantis
08/23/2023, 2:17 PMEmil Kantis
08/23/2023, 2:18 PM{ logAndNack(logger, message)(it) },
Youssef Shoaib [MOD]
08/23/2023, 2:19 PMEmil Kantis
08/23/2023, 2:26 PMYoussef Shoaib [MOD]
08/23/2023, 2:28 PMlogAndNack(message, it)
which is even nicer.
In general, if you find yourself repeating a set of parameters pretty often, it's time to consider if they'd work as context receivers instead. This eliminates a good chunk of use-cases for currying.Emil Kantis
08/23/2023, 2:34 PMYoussef Shoaib [MOD]
08/23/2023, 2:35 PMEmil Kantis
08/23/2023, 2:35 PMsimon.vergauwen
08/28/2023, 7:37 AMThat's why Kotlin isn't really intended to do currying.100% this, although I've request several times to allow calling
suspend
lambdas where inline
lambdas are allowed not sure if this ever made it into a YouTrack issue 🤔Emil Kantis
08/28/2023, 7:40 AM