Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
iex(7)> map = %{name: "shahryar" , likes: "programming", where: "dallas"}
%{likes: "programming", name: "shahryar", where: "dallas"}
iex(8)> Map.keys map
[:likes, :name, :where]
iex(9)> Map.values map
["programming", "shahryar", "dallas"]
iex(10)> map[:name]
iex(12)> map1 = Map.drop map, [:where, :likes]
%{name: "shahryar"}
iex(13)> map2 = Map.put map, :also_likes,"Ruby"
%{also_likes: "Ruby", likes: "programming", name: "shahryar",
where: "dallas"}
iex(14)> Map.keys map2
[:also_likes, :likes, :name, :where]
iex(15)> Map.has_key? map1, :where
iex(16)> {value, updated_map } = Map.pop map2, :also_likes
{"Ruby", %{likes: "programming", name: "shahryar", where: "dallas"}}
iex(17)> Map.equal? map, updated_map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment