Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/Collections/Elixir/collections-4.elixir
Normal file
15
Task/Collections/Elixir/collections-4.elixir
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
empty_map = Map.new #=> %{}
|
||||
kwlist = [x: 1, y: 2] # Key Word List
|
||||
Map.new(kwlist) #=> %{x: 1, y: 2}
|
||||
Map.new([{1,"A"}, {2,"B"}]) #=> %{1 => "A", 2 => "B"}
|
||||
map = %{:a => 1, 2 => :b} #=> %{2 => :b, :a => 1}
|
||||
map[:a] #=> 1
|
||||
map[2] #=> :b
|
||||
|
||||
# If you pass duplicate keys when creating a map, the last one wins:
|
||||
%{1 => 1, 1 => 2} #=> %{1 => 2}
|
||||
|
||||
# When all the keys in a map are atoms, you can use the keyword syntax for convenience:
|
||||
map = %{:a => 1, :b => 2} #=> %{a: 1, b: 2}
|
||||
map.a #=> 1
|
||||
%{map | :a => 2} #=> %{a: 2, b: 2} update only
|
||||
Loading…
Add table
Add a link
Reference in a new issue