Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin default constructors

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()?

like image 385
uptoyou Avatar asked Mar 13 '26 11:03

uptoyou


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.

like image 98
crgarridos Avatar answered Mar 15 '26 02:03

crgarridos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!