https://kotlinlang.org logo
#getting-started
Title
# getting-started
a

Ayfri

04/26/2022, 8:59 PM
Hi, how can I set an argument of a data class as having a
internal set
?
a

Alejandro Moya

04/26/2022, 9:37 PM
hope that helps 😄
e

ephemient

04/26/2022, 10:37 PM
maybe not a concern in your case specifically, but in general `internal`/`private` doesn't really work for a data class constructor parameters; external code can always
.copy()
and change anything
if you have any significant logic or API/ABI requirements, then
data class
is probably not the right tool
a

Ayfri

04/27/2022, 5:20 AM
Yes I know but I'm using https://github.com/komapper/komapper which requires data classes for the wrappers so I don't really have a choice for this But I'll use a private field with a different name plus a getter to the real field and use annotations to rename them to what Komapper wants
2 Views