3 ms·
The copy methods that Kotlin generates construct a new instance of the class with the updated fields - so any validation done in the constructor would in fact b
by snuxoll 5y ago
The copy methods that Kotlin generates construct a new instance of the class with the updated fields - so any validation done in the constructor would in fact be done again.
- valenterry 5y agoYes, that's correct. But instead of catching the error at that point, you would probably rather want to disable these methods from the beginning so that someone cannot even make the mistake of using them and has to go through some custom defined method instead.