I was reading the documentation
and some others like
...Of which creates instances of collections.
A question came up, since in the documentation it’s written
fun <K, V> mutableMapOf(): MutableMap<K, V>
Returns an empty new MutableMap.
MutableMap is an interface,
and it isn’t stated which concrete implementation of it is returned by default.
After a while of searching,
here the default implementations seem to be stated.
Is there a reason why this is not stated directly in the API’s documentation?
Q2. This is a following question
When using these standard library functions, how could one change this default implementation and return some other implementations of the interfaces instead?
mapof(), how could I change the behavior such that it returns an
HashMap instead of the default implementation
Is this also a right way to inspect the concrete implementation? Please correct me if I’m wrong
val map = mutableMapOf<Int, Any?>() println(map::class.qualifiedName)