Is there a way to have a secondary constructor for...
# announcements
n
Is there a way to have a secondary constructor for a data class that does some processing on the parameters before creating a new instance? For example let's say I have a
Car
data class, it has a model and a color. Let's say that I want to be able to create this class by passing in a string that contains the data that I need. In order to create a new car I would need to parse this string to get the parameters that I need to pass to the car constructor. The problem is that a secondary constructor must refer to the primary constructor, which I can't do until I parse the string. How would I go about doing this?