I’m still a fan of data classes simply because the...
# announcements
m
I’m still a fan of data classes simply because they’re more flexible. Not only do you get the copy method, you can also use them where immutability isn’t desired. As much as I love immutability, sometimes we need something different. It’s the same with imperative vs. declarative programming. Sure, the latter is usually preferable, but I’d like the programming language to be flexible about it. Now, if it ever turns out that a stricter version of data classes is beneficial, it can still be introduced. Simply add a modifier, like
strict data class
or even
record class
, and then we can use that as well.
s
for now there's
@JvmRecord
and in the future there'll be
value class
(with multiple properties).
m
Good point! I haven’t looked into the new records annotation yet, but if that restricts the kotlin class to what a java record can do, that’s cool 🙂