smcvb
06/16/2017, 2:16 PMabstract class AbstractExample(
open val paramOne: Int,
open val paramTwo: String
)
And, the following implementation of the example abstract class:
data class ExampleImpl(
override val paramOne: Int,
override val paramTwo: String,
val paramThree: Boolean
) : AbstractExample(paramOne, paramTwo)
I have to override paramOne
and paramTwo
, because of the following message I get: 'Data class primary constructor must have only property (val / var) parameters'
I'd ideally however have an ExampeImpl
like so:
data class ExampleImpl(
paramOne: Int,
paramTwo: String,
val paramThree: Boolean
) : AbstractExample(paramOne, paramTwo)
Or this at least looks cleaner to me, since this doesn't mean I need to instantiate paramOne
and paramTwo
for ExampleImpl
again and thus use the variables and getter/setter from the AbstractExample
as I'd prefer to.
As far as I know this currently isn't a possibility, hence I dropped in this channel.kirillrakhman
06/16/2017, 2:50 PMabstract class Base {
abstract val paramOne: Int
abstract val paramTwo: String
}
smcvb
06/16/2017, 3:23 PMsmcvb
06/16/2017, 3:24 PM