Member-only story
Elixir Associative Data Structures: Maps and Keyword Lists
Understand how maps and keyword lists work
Associative data structures allow one to associate a key with a given value. In Python, they are called dictionaries; in JS, they are called literal objects. In Elixir, there are two: keyword lists and maps.
Keyword List
They are typically used to send options to functions. Let’s see an example where a keyword list is used.
Suppose we have a binary with three numbers separated by spaces, and we want to get a list containing these numbers. This can be done easily by placing the binary string and the separator in the split function inside the String module.
But what happens when we have more spaces in the binary string?