Hello, everyone! I have a minor aesthetic question...
# announcements
a
Hello, everyone! I have a minor aesthetic question regarding the style of creating collections in Kotlin: when I want to create a collection of a specific type (e.g., HashMap) due to performance constraints, what is the preferred way of creation,
hashMapOf<K, V>()
or
HashMap<K, V>()
? Similarly, if I pass a method reference, which is preferred,
::hashMapOf
or
::HashMap
? I know the factory methods are just calling the constructors, and they are symmetrical to the factory method
mutableMapOf
(same for sets and lists), but I know the concrete type I want and I'm not sure if there are any guidelines regarding this. What I actually want is to pick one of these two methods of creating collections and stick with it across the whole code-base for consistency, I'm just wondering what others do regarding this and if there actually is a guideline.