Just wondering if this is possible.
What I would actually like to do is check and possibly modify one of the arguments before it is stored as a val.
Alternatively, I could use an overload and make the default constructor private. In which case I would also like to make private the default factory constructor in the companion object, how would I do that?
Many thanks.
Adam
edit: well i figured out that making the default constructor private also makes the default factory constructor private, so i have a solution, i’m still interested to know if the default constructor is overridable though
The presence of secondary case class constructors don’t cause the compiler to produce additional factory methods in the class’s companion, so you won’t get the convenience of
CaseClaseName(«secondary constructor parameter list»>)for creating them. You’ll have to use thenewkeyword.It’s better to put the sort of logic you’re describing in alternate factory methods in the companion object and stick to using the primary constructor.