Skip to content

Instantly share code, notes, and snippets.

@haiy
Created January 7, 2015 10:17
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 haiy/4144a27441c2db858d2f to your computer and use it in GitHub Desktop.
Save haiy/4144a27441c2db858d2f to your computer and use it in GitHub Desktop.
scala map merge
def merge(m1: Map[String, Int], m2: Map[String, Int]): Map[String, Int] =
m1 ++ m2.map { case (k, v) => k -> (v + m1.getOrElse(k, 0)) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment