Skip to content

Instantly share code, notes, and snippets.

@aembleton
Created August 19, 2016 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aembleton/922e27b352dba5bfa329dce5f5ee50bc to your computer and use it in GitHub Desktop.
Save aembleton/922e27b352dba5bfa329dce5f5ee50bc to your computer and use it in GitHub Desktop.
Create a map from a list of Strings. Split the string with a splitter String. Useful for reading in a list of comma seperated String and converting them into a map.
fun List<String>.mapWith(split:String) = this.map {
val components = it.split(split, limit=2)
components[0].trim() to components[1].trim()
}.toMap()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment