Any nice way of handling this use case with the Ko...
# android
c
Any nice way of handling this use case with the Kotlin
with
keyword?
Copy code
with(myFragmentBinding){
   viewId.text = stateDataClass.name
   viewId2.text = stateDataClass.lastName
   viewId3.text = stateDataClass.phoneNumber
}
And I was thinking if there is any nice way of also not repeating the right part. Something like
with(Pair(binding, modelClass))
doesn’t look pretty nice to me as it might look a little bit ugly and not intuitive (
first.viewId.text = second.name
) which I don’t like. A nested with is also ugly IMO. Any opinions, thoughts?
m
staeDataClass.let {
Copy code
viewId.text = it.name
   viewId2.text = it.lastName
   viewId3.text = it.phoneNumber
}