Sam Garfinkel
03/12/2020, 4:18 PMthis
is not the receiver? For instance, if I’m wrapping an existing API in a DSL, a fun String.bar()
might behave differently depending on what this
is. I’m not able to subclass the wrapped API data type as it’s final, and inline classes don’t provide delegates apparently. I thought this would work:
class Foo {
fun doSomething(it: String) {
// TODO
}
}
inline class Bar(val foo: Foo) {
fun String.doSomething() = doSomething(this)
}
But Bar(Foo()).doSomething("hello")
is undefined.Sam Garfinkel
03/12/2020, 4:24 PMBig Chungus
03/12/2020, 4:36 PMEvan R.
03/12/2020, 4:43 PMfun Bar.barAction() {
val string = "something"
string.doSomething()
}
Evan R.
03/12/2020, 4:44 PMSam Garfinkel
03/12/2020, 4:49 PM