Klitos Kyriacou
06/06/2025, 5:25 PMclass C {
fun foo(block: Int.() -> Unit) {
123.block()
}
}
fun C.foo(block: String.() -> Unit) {
"hello".block()
}
fun main() {
val c = C()
c.foo {
println((this as String).length) // this is Int, want String
}
}
Michael Krussel
06/06/2025, 6:07 PMRuckus
06/06/2025, 7:21 PMimport foo as fooString
class C {
fun foo(block: Int.() -> Unit) {
123.block()
}
}
fun C.foo(block: String.() -> Unit) {
"hello".block()
}
fun main() {
val c = C()
c.fooString {
println(length)
}
}
https://pl.kotl.in/yWafqWUx9