Hi , is there way to make this code more cute ? ```val index = liveFxRates.indexOfFirst { result.da...
a
Hi , is there way to make this code more cute ?
Copy code
val index = liveFxRates.indexOfFirst { result.data.isCurrencyPairEqual(fxLiveRateGainLoss =  it) }
if(index > -1) {
    liveFxRates.removeAt(index)
    liveFxRates.add(index, liveFxRates[index].copy(buyValue = "-", sellValue = "-"))
}
g
You can use https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/set.html to replace the element Idk if
indexOfFirstOrNull
exists, but if so you can use
?.let
to get the index:
Copy code
liveFxRates.indexOfFirstOrNull { result.data.isCurrencyPairEqual(fxLiveRateGainLoss =  it) }?.let { index -> 
    liveFxRates.set(index, liveFxRates[index].copy(buyValue = "-", sellValue = "-"))
}
Or
Copy code
val index = liveFxRates.indexOfFirst { result.data.isCurrencyPairEqual(fxLiveRateGainLoss =  it) }
if(index > -1) {
    liveFxRates.set(index, liveFxRates[index].copy(buyValue = "-", sellValue = "-"))
}
otherwise
1
a
@Gabriel Lasso thank you