Marc Knaup
12/24/2019, 12:00 PM.toList()
, .map()
, .filter()
, listOf()
, etc. use some immutable List
subclass internally, so that subsequent calls to .toList()
don’t have to create another copy? 🙂
Would be great for defensive copy patterns, since you don’t know whether the list you get is immutable or not.miha-x64
12/24/2019, 12:07 PM.toXxx()
is copying by definitionMarc Knaup
12/24/2019, 12:09 PMmiha-x64
12/24/2019, 12:12 PM.asXxx()
for returning view on this
collectionMarc Knaup
12/24/2019, 12:13 PM.asXX()
could be immutable depending on whether the underlying collection is immutable, hence .toList()
could even here just return this
in some cases 😄