Join Slack
Powered by
How I create a class with two "constructors" that ...
# getting-started
f
Frodrigues
11/10/2019, 5:32 PM
How I create a class with two "constructors" that on does not receive any value so run a big code block to init the properties and another that receives the properties already initialized?
m
molikuner
11/10/2019, 6:58 PM
That's the only way I know of:
https://pl.kotl.in/nUsCnILEs
f
Frodrigues
11/10/2019, 10:43 PM
thanks
m
Matteo Mirk
11/20/2019, 1:36 PM
I would favor class B from the above snippet. I suggest reading deeper here:
https://kotlinlang.org/docs/reference/classes.html#constructors
(secondary constructors paragraph)
f
Frodrigues
11/21/2019, 10:37 PM
Yeah, I was a bit clunky with constructors in kotlin.
2
Views
Open in Slack
Previous
Next