I want to check if the type of a parameter given to a function in Elixir is a Dictionary. How do I do this?
First you have to be aware that Elixir supports 2 Dictionary types
map = %{}
dict = HashDict.new
Both types however need to be checked with Erlangs native :erlang.is_map
.
def some_fun(arg) when :erlang.is_map(arg) do
#do your thing
end
More info can be found under sections 7.2 and 7.3 (http://elixir-lang.org/getting_started/7.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With