Daniel
02/06/2019, 10:09 PMtoReplace
part out with this code snipped to replace it (the original type is not Int
). But that doesn't look very clean.
Also when you convert the list to a mutable list and remove the toReplace
part it does'nt look very elegant.
fun replaceInList(list: List<Int>, toReplace: List<Int>, replacement: List<Int>) = with(list) {
subList(0, indexOf(toReplace.first)) + replacement + subList(indexOf(toReplace.last) + 1, size)
}