In Elixir, map is the tool to use when we need a very simple key/value store. A map is a data type for associative collections (or dictionaries).
The Map
module is an implementation of the Dict API. The following is the Dict documentation page:
In this recipe, we will create an in-memory database of the English Premier League, where we will keep the current points, number of played games, and the club name. We will be creating a map to hold the league and a map for each team. This will be a map of maps! The steps are as follows:
We will create the map to hold the League data:
iex(1)> premier_league_2013 = %{}
Now, it's time to add some data about the teams:
iex(2)> man_city = %{:position=> 1, :points=> 86, :played=> 38, :name=> "Manchester City"} iex(3)> liverpool = %{:position =...