Roman Elizarov
1 min readJan 3, 2019

--

You can do this with inline functions:

inline fun runTwice(code: () -> Unit) { code(); code() }

Now you can use runTwice with both suspend and regular functions and compiler automatically infers the corresponding type.

--

--

Roman Elizarov
Roman Elizarov

Written by Roman Elizarov

Project Lead for the Kotlin Programming Language @JetBrains

No responses yet