Associative array/Merging: Difference between revisions

Add Elixir impl
(Add Elixir impl)
Line 414:
name Rocket Skates
</pre>
=={{header|Elixir}}==
Elixir has a built-in hashmap type, called [https://hexdocs.pm/elixir/Map.html Map].
<lang Elixir>base = %{name: "Rocket Skates", price: 12.75, color: "yellow"}
update = %{price: 15.25, color: "red", year: 1974}
result = Map.merge(base, update)
IO.inspect(result)</lang>
{{out}}
<pre>%{color: "red", name: "Rocket Skates", price: 15.25, year: 1974}</pre>
The above sample uses [https://hexdocs.pm/elixir/Atom.html atoms] as the key type. If strings are needed, the <code>base</code> map would look like this:
<lang Elixir>base = %{"name" => "Rocket Skates", "price" => 12.75, "color" => "yellow"}</lang>
 
=={{header|F_Sharp|F#}}==
<lang fsharp>