Skip to content

Instantly share code, notes, and snippets.

@ch8n
Created October 12, 2020 13:37
Show Gist options
  • Save ch8n/390701cc633d8c1c636f61abc4dc9ade to your computer and use it in GitHub Desktop.
Save ch8n/390701cc633d8c1c636f61abc4dc9ade to your computer and use it in GitHub Desktop.
linkedhashMap definition in kotlin
fun <K, V> linkedMapOf(vararg pairs: Pair<K, V>): LinkedHashMap<K, V>
= pairs.toMap(LinkedHashMap(mapCapacity(pairs.size)))
// this factory function takes pair and uses LinkedHashMap'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