ok, I was asking because there's some properties o...
# announcements
z
ok, I was asking because there's some properties on the class I'd rather not be public, but maybe I'll have to live with it
d
You can have the extension function be just a thin "helper wrapper" around an
internal
function on the class.
That way you don't have to expose anything on the class
z
when I made the functions it calls internal, I get java.lang.NoSuchMethodErrors when running tests
d
That... should not happen! 😄
z
yeah, the IDE says it's fine, but then the tests blow up
wait, I did a clean and rebuild and now my tests are passing
thanks 🙂
s
technically speaking, you may be able to implement the curiously recurring template pattern here, since you need a few classes to implement this behavior
assuming, of course, this abstract class isn’t meant for public consumption
z
it is
s
Ah, in that case never mind
z
🙂
s
can’t exactly ask consumers to properly implement leaf classes in that case
z
yeah, but I have it working the way that I want it to now
👍 1
a
you can do it without an extension function.
Copy code
class Foo {
    fun foo(block: Foo.() -> Unit) = this.block()
}
d
That does not account for subclassing, where you want the correct type to be passed into the lambda.
a
I just wanted to point out that its possible to do it without an extension method. If subclasses are involved, he could override the method in the subclass