Created
October 12, 2020 13:25
-
-
Save ch8n/9f90468d5ca0fcbcb938451fd7b1942c to your computer and use it in GitHub Desktop.
hashMapOf definations kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V> | |
= HashMap<K, V>(mapCapacity(pairs.size)).apply { putAll(pairs) } | |
// this factory function takes pair and uses HashMap's second constructor which | |
// start off with the object capacity as the number of pairs passed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment