Braces should be optional for object expressions

#1

In many cases, an object expression is used to override functionality:

val o = object : SomeInterface {
    override fun doSomething() {
        println("Hello!")
    }
}

However, when using an object expression to extend an abstract class (that has no abstract members remaining) the braces can be extraneous when you’re not overriding anything:

val o = object : SomeAbstractClass() {
    // nobody's home
}

I propose that the object expression braces be made optional, such that when there are no member definitions needed for a valid object expression, they can be omitted:

val o = object : SomeAbstractClass()

Thanks!

3 Likes