Hi there I have gone thru the kotlin documentation and haven't found anything. What I want to do is have a generic thar must be a data class, something like
data class MyData(val pop1:Long,val pop2:String,...)
fun class MyGenericClass<T : isDataClass>(o : T){
// This is the important part
fun useCopy(value : Long) = t.copy(pop1 = value)
}
What I really need to achieve is to be able to use the copy function of data classes in a generic way(pop1 will always be a member of my data classes)
Thanks in advance
pop1member? My suggestion would be to define an interface, and then have your (data) classes inherit from that.sealed classor an interface and then use reflection with named arguments, although it probably would make sense to rethink your problem. This is an unusual use case.