4 ms·
Do note that record types aren't closed even with a private constructor. The compiler will generate a protected constructor for copy operations which can then b
by S04dKHzrKT 2y ago
Do note that record types aren't closed even with a private constructor. The compiler will generate a protected constructor for copy operations which can then be inherited from. To prevent this, you have to define your own protected constructor and have it throw a runtime exception if it isn't a valid case.
- ctenb 2y agoYou are technically correct (the best kind of correct), but in practice I've not found this to be a problem, certainly not something that is ofsetting the vast usefulness of this data pattern.
- S04dKHzrKT 2y agoI've found the same to be true as well.