Kotlin make constructor of data class accept both List and MutableList but store a mutable instance of them
问题 I want to make a data class which can accept both list and mutable-list and if the list is instance of MutableList then directly make it a property else if it is a List then convert it into a MutableList and then store it. data class SidebarCategory(val title: String, val groups: MutableList<SidebarGroup>) { constructor(title: String, groups: List<SidebarGroup>) : this(title, if (groups is MutableList<SidebarGroup>) groups else groups.toMutableList()) } In the above code Platform declaration