Daniele B
08/13/2020, 9:18 PMdata class State (
val aField : String
val bField : String
val cField : String
)
I would like to wrap this copy function:
wrapperobject.state = wrapperobject.state.copy (aField = aValue, bField = bValue)
inside a custom method like this:
wrapperobject.changeState(aField = aValue, bField = bValue)
what would be the code for it?
I am not sure how to define the argument of the changeState
methodShawn
08/13/2020, 9:26 PMclass WrapperObject(var state: State)
fun changeState(aField: String, bField: String) {
state = state.copy(aField = aField, bField = bField)
}
}
Daniele B
08/13/2020, 9:29 PMDaniele B
08/13/2020, 9:30 PMShawn
08/13/2020, 9:32 PMShawn
08/13/2020, 9:33 PMDaniele B
08/13/2020, 9:33 PMDaniele B
08/13/2020, 9:34 PMDaniele B
08/13/2020, 9:34 PMDaniele B
08/13/2020, 9:35 PMShawn
08/13/2020, 9:35 PMcopy
on data classes is a unique caseDaniele B
08/13/2020, 9:36 PMDaniele B
08/13/2020, 9:36 PM