Kotlin default constructors

Viewed 293

Are all this Kotlin snippets equivalent?

open class A
// A() - explicit call of A default constructor
class B : A()

using super() :

open class A

class B : A {
    constructor() : super()
}

using super :

open class A

class B : A {
    constructor() : super
}

nothing is specified:

open class A

class B : A {
    constructor()
}

So, what is a difference between super and super() in this cases, and if i understand right - last snippet implicitly calls super()?

1 Answers

What is a difference between super and super() in this cases

Nothing, both are the same

Last snippet implicity calls super()

Yes, it does.

Related