Is it possible to define an abstract function as e...
# android
Is it possible to define an abstract function as extension function?
Copy code
sealed class Foo {
    abstract fun bar()

class A : Foo()
class B : Foo()

/* in another file */

fun {
  // implementation
It seems it's not possible but maybe there is something similar? I just want to move the implementation of
to other files because the LOC for the implementation is huge. I want to avoid a file with thousands of LOC. Any ideas?
I don't think there is any way to do that. In Kotlin 1.5, you will be able to move class A and class B to different files. You can enable the 1.5 features currently as a preview.
ok thanks for the hint 🙂
extension methods are implemented as static methods, which is why they cannot override an abstract method.
Another option is to create an internal extension function and then have the bar function call that extension function.
❤️ 1
Cool idea! I will go with this solution
interesting problem