<How to create a default value for a sealed class ...
# forum
r
How to create a default value for a sealed class property? Hi, If I have a sealed class which is implemented by data classes, how can I make a property shared amongst each implementation of the sealed class have a default value? For example, in a small game, where players have a name and chips, in order to give all players by default 100 chips, I currently have to do something like this (which looks very ugly): sealed class Player { abstract val name: String abstract val chips: Int companion object { const val DEFAULT_CHIPS =...