Alright. If i use a secondary constructor i have t...
# announcements
h
Alright. If i use a secondary constructor i have to provide defaults for the non-nullable fields, which feels wrong to me. And the init block is just extra boilerplate, that i would rather not type. Would be cool if there was some way to explicitly call the setter from the primary constructor
k
Are you sure you have to provide defaults? Did you accidentally keep an empty primary constructor
()
?
h
Absolutely sure. Also i will be unable to use val, since it has to initialized from the primary constructor
So i guess the init block is the best way
k
Let me try that, I'm not convinced.
h
Even if I can, I will still have to type “this.email = email”, so it requires the same boilerplate as the init block (but wouldn’t assign and reassign)
But it seems you are right that i don’t need defaults with the secondary constructor, my bad
k
Sure, you'll still nice a bit of boilerplate.
h
Right. Another odd thing is that IntelliJ suggests that i convert the secondary constructor to a primary, even though they apparently have different semantics. But thanks for your time @karelpeeters, I appreciate it 🙂
k
That's a bug then, I'd report it on YouTrack. Good luck!