Andrew Gazelka
04/28/2019, 4:17 PMList
and expect the contents to be the same, I should create a copy, right? (since the List
might also be Immutable) ... is there any good way to only copy if it is mutable or would that be too much of a micro-optimization?Ryan Benasutti
04/28/2019, 4:41 PMrobstoll
04/28/2019, 4:42 PMlouiscad
04/28/2019, 8:26 PMpablisco
04/28/2019, 10:23 PMfun <T> List<T>.ensureInmutable() = when(this) {
is MutableList -> this.toList()
else -> this
}
This is assuming that calls to Java code with a List would assume that is a MutableList (which I'm not 100% sure it does)