3 ms·
I perhaps should have been more explicit about the goal rather than the method, since sealing records is only one part of this. This is all in service of priva
by dwohnitmok 7y ago
I perhaps should have been more explicit about the goal rather than the method, since sealing records is only one part of this.
This is all in service of private constructors. You effectively cannot have private constructors for data classes in Kotlin because the copy method remains public and cannot be "turned off." `sealed abstract case class` in Scala gets rid of that.
Private constructors for record types is a fantastic light-weight way of incorporating runtime checks into compile-time types.