Join Slack
why can’t we add a constructor to a object class{}?
# kotlin-native
b
Brian Donovan
09/15/2021, 5:34 PM
why can’t we add a constructor to a object class{}?
e
edrd
09/15/2021, 5:36 PM
Because
object
means an instance, not a class, so you cannot instantiate it and therefore a constructor doesn't make sense
b
Brian Donovan
09/15/2021, 5:37 PM
thank you
🤘 1
Brian Donovan
09/15/2021, 5:39 PM
so what is the difference from a object class{} vs a singleton?
e
edrd
09/15/2021, 5:39 PM
no difference, in Kotlin
object
is meant for implementing singletons
edrd
09/15/2021, 5:41 PM
btw,
#getting-started
is more suited for these kinds of questions
Open in Slack
Previous
Next
kotlinlang
A modern programming language that makes developers happier.
Powered by