diff --git a/resaca/src/commonMain/kotlin/com/sebaslogen/resaca/ScopedViewModelContainer.kt b/resaca/src/commonMain/kotlin/com/sebaslogen/resaca/ScopedViewModelContainer.kt index f3e33ff7..0e4713a7 100644 --- a/resaca/src/commonMain/kotlin/com/sebaslogen/resaca/ScopedViewModelContainer.kt +++ b/resaca/src/commonMain/kotlin/com/sebaslogen/resaca/ScopedViewModelContainer.kt @@ -359,7 +359,7 @@ public class ScopedViewModelContainer : ViewModel(), LifecycleEventObserver { // Cancel all coroutines, Closeables and ViewModels hosted in this object val objectsToClear: MutableList = scopedObjectsContainer.values.toMutableList() while (objectsToClear.isNotEmpty()) { - val lastObject = objectsToClear.removeLast() + val lastObject = objectsToClear.removeAt(objectsToClear.lastIndex) clearLastDisposedObject(lastObject, objectsToClear) } scopedObjectKeys.clear() // Clear all keys