Ali
01/19/2022, 12:14 PMdata class A(
val metadata: String
){
data class B(
val metadata: String
)
}
fun updateData(data: Any){
when(data){
is A -> {// update A metadata value
}
is A.B -> {// update B metadata value
}
}
}
want to update the value of metadata
for both data class by using the same logic and don't want to write it twice inside when statement. How can I do it by writing the logic only once?Joakim Forslund
01/19/2022, 1:15 PMUmar Ata
01/19/2022, 2:59 PMAli
01/19/2022, 3:32 PMAli
01/19/2022, 3:33 PMJoakim Forslund
01/19/2022, 3:35 PMAli
01/19/2022, 3:45 PM