Hi guys. Is there a simple way to do cyclic data c...
# announcements
z
Hi guys. Is there a simple way to do cyclic data classes? If I do it normaly most of the methods will break.
s
Would you mind expanding on what you mean by “cyclic”?
z
data class Parent(child: Child); data class Child(parent: Parent) Something like this.
e
Why would you want it to be a data-class? What for?
3
z
They are classes I use on services, and might want to save on database. I researched a bit, and found I can just define the parent reference outside of the propeties. However, I think I would have to make it nullable, which I`m not sure I want.
Like data class Parent(child: Child); data class Child(){var parent: Parent?} or something.
l
That doesn't tell why you want the
data
modifier, does it?
z
Aren`t data classes used for seralizing?
e
Usually “serailizable” classes are serailized. Data classes are used for simple data containers.