Yousef
09/28/2021, 3:26 PMdata class Category(
val id: UUID,
var title: String,
var slug: String,
var subCategories: List<Category>
)
Paul Griffith
09/28/2021, 3:30 PMYousef
09/28/2021, 3:32 PMTobias Berger
09/28/2021, 3:36 PMsubcategories
property.
If you don't need data classes, another option is to have a simple Category class without the subcategories and another "TopLevelCategory" class that inherits from it and adds the subcategories list. All a matter of style and preference, I myself would also go with the approach mentioned by @Paul GriffithYousef
09/28/2021, 3:40 PM