Why there cannot be more than one primary constructor? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why there cannot be more than one primary constructor?

7th Oct 2020, 4:36 AM
Rajan Singh
3 Answers
+ 5
The secondary all must call the primary as that is where the storage is allocated in a wrapper that nests your primary. Have two primaries would cause major issues with that design as the compiler can not guarentee the properties were properly initialized.
11th Oct 2020, 7:12 AM
John Wells
John Wells - avatar
+ 1
What is you question, maybe I can help you?
9th Oct 2020, 5:49 PM
LeChuck_42
LeChuck_42 - avatar
0
Hi, As in Kotlin we have two types of constructors " Primary" and "Secondary". There can be multiple secondary constructor but only one primary construct constructor. Why?
10th Oct 2020, 1:53 AM
Rajan Singh