Combining two maps on same key in Elixir

Viewed 4050

I'm pretty new to Elixir and just wanted to find what the best way is to combine two maps with on same key. To be more specific:

name_map = %{
  105 => "Jim",
  48 => "Maria",
  62 => "Karen",
  888 => "Foo"
}

job_map = %{
  105 => "Social worker",
  48 => "Programmer",
  62 => "Teacher",
  999 => "Bar"
}

and I am trying to get

combined_map = %{
  105 => %{"name" => "Jim", "job" => "Social worker"},
  48 => %{"name" => "Maria", "job" => "Programmer"},
  62 => %{"name" => "Karen", "job" => "Teacher"},
  888 => %{job: nil, name: "Foo"},
  999 => %{job: "Bar", name: nil}}
}

Thanks in advance for any help!

3 Answers
Related