@north don’t really know if it’s ok, but this works:
Copy code
interface TestInterface {
fun apply(str: String): String
}
fun TestInterface(lambda: (String) -> String): TestInterface {
return object : TestInterface {
override fun apply(str: String): String = lambda(str)
}
}
fun main(args: Array<String>) {
var test = TestInterface { str: String -> str.apply { println(str) } }
test.apply("test")
}
You can throw some inlines in there.
n
north
04/28/2017, 3:00 PM
kojdecki: thank you. this was a solution I also found in one of the linked threads. To be fair, I think this language limitations should be lifted. Adding boiler plate code to our interfaces is a workaround.