Created
April 23, 2017 07:21
-
-
Save shahryarjb/41208373b1273126f7ee39f5a6e35a5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
"shahryar" | |
iex(11)> map.name | |
"shahryar" | |
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 | |
false | |
iex(16)> {value, updated_map } = Map.pop map2, :also_likes | |
{"Ruby", %{likes: "programming", name: "shahryar", where: "dallas"}} | |
iex(17)> Map.equal? map, updated_map | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment