Hey all, sorry if this has already been brought up...
# language-proposals
b
Hey all, sorry if this has already been brought up but I couldn't find anything about this. I was wondering if that would be a good idea to add a keyword like
empty
(or something else) that could be added to an abstract class or an interface. The idea would be that adding the keyword would implement every method with an empty implementation. That would be particularly helpful when you want to implement only one method of an interface that has a lot of methods. E.g. :
Copy code
class MyClass : MyInterface by empty MyInterface() {
  override fun onlyOneMethod() {
    //...
  }
}
Of course, it would return
null
for nullable object, 0 for numeric value, false for boolean and "" for String. For non-nullable objects return, an implementation would still be required. This keyword could also be used to create a new class :
Copy code
empty class MyInterface()
I understand this can be easily achieved by generating an empty implementation of an interface through the IDE but this keyword would make the code less verbose
🙈 1