3 ms·
But if that’s the case, then a record is the wrong data type for what you’re doing anyway, since you can call the primary constructor at any point with those sa
by wtetzner 4y ago
But if that’s the case, then a record is the wrong data type for what you’re doing anyway, since you can call the primary constructor at any point with those same un-validatable values.
It’s not “with” that’s problematic. If a record doesn’t work for what you’re trying to do, just use a class.
Though I will say that this is why I generally think ML’s (i.e. OCaml, Standard ML) approach to encapsulation with modules is generally superior to using classes for encapsulation.
- ivan_gammel 4y agoHave a look at the proposal. Half of it is dedicated to regular classes, which makes sense, because record is just a syntactic sugar in Java at the moment. Also this: https://news.ycombinator.com/item?id=34398982 https://news.ycombinator.com/item?id=34398982