Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
10
Task/Enumerations/Elixir/enumerations-2.elixir
Normal file
10
Task/Enumerations/Elixir/enumerations-2.elixir
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
fruits = [{:apple, 1}, {:banana, 2}, {:cherry, 3}] # Keyword list
|
||||
fruits = [apple: 1, banana: 2, cherry: 3] # Above-mentioned different notation
|
||||
fruits[:apple] #=> 1
|
||||
Dict.has_key?(fruits, :banana) #=> true
|
||||
|
||||
fruits = %{:apple=>1, :banana=>2, :cherry=>3} # Map
|
||||
fruits = %{apple: 1, banana: 2, cherry: 3} # Above-mentioned different notation
|
||||
fruits[:apple] #=> 1
|
||||
fruits.apple #=> 1 (Only When the key is Atom)
|
||||
Dict.has_key?(fruits, :banana) #=> true
|
||||
Loading…
Add table
Add a link
Reference in a new issue