do they not already?
# stdlib
b
do they not already?
r
benleggiero: They don't.
listOf()
returns an ordinary
ArrayList
, for example. The immutability is only in the interface, because you're getting a
List
, but you can simply cast that to
MutableList
and do whatever you want.
😨 2
😰 1
e
well, the return type of listOf<T>() is List<T> which is “immutable”, iirc
but you can cast that to a MutableList
b
Yeah, after looking into the source code, the return type of
listOf
functions is the interface
List
, but unfortunately the implementation chosen is
ArrayList
, which is a
MutableList