Last active
April 23, 2017 14:48
-
-
Save shahryarjb/3be791009a1f500da10dc54f77275b86 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(28)> person1 = %{ name: "shahryar" , height: 1.88} | |
%{height: 1.88, name: "shahryar"} | |
iex(29)> %{ name: a_name } = person1 | |
%{height: 1.88, name: "shahryar"} | |
iex(30)> a_name | |
"shahryar" | |
iex(31)> %{ name: _ , height: _ } = person1 | |
%{height: 1.88, name: "shahryar"} | |
iex(32)> %{ name: "shahryar" } = person1 | |
%{height: 1.88, name: "shahryar"} | |
iex(33)> %{ name: _ , weight: _ } = person1 | |
** (MatchError) no match of right hand side value: %{height: 1.88, name: "shahryar"} | |
#V2 | |
people = [ | |
%{ name: "Grumpy", height: 1.24 }, | |
%{ name: "Dave", height: 1.88 }, | |
%{ name: "Dopey", height: 1.32 }, | |
%{ name: "Shaquille", height: 2.16 }, | |
%{ name: "Sneezy", height: 1.28 } | |
] | |
IO.inspect(for person = %{ height: height } <- people, height > 1.5, do: person) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment