Keyword listsΒΆ
Keyword lists is a merged structure between lists and tuples.
iex(1)> color = [{:primary, "red"}, {:secondary, "green"}]
[primary: "red", secondary: "green"]
To access the elements, you can use:
iex(2)> color[:primary]
"red"
You can also use the following syntax:
iex(3)> colors = [primary: "red", secondary: "green"]
[primary: "red", secondary: "green"]