def my_function(%{direction: some_var})
# ...do some stuff with some_var ...
end%{ ignored: "fred", direction: :north}defmodule ExactMap do
def match(map, keys), do: Map.keys(map) == keys
endiex> ExactMap.match(%{ignored: "fred", direction: :north}, [:direction])You can match on all keys and include a guard on map_size.
Bruno's answer about structs isn't quite accurate. There's no protection against structs with extra fields added via Map.put/3. If you always update via the map update syntax %{struct | :key => "value"} then you should be fine, but there nothing but convention protecting you from messing with the strict internals by treating it as a map.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/0b8f5ec3-9965-4527-966a-beeeb219fb86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/e4f1e75f-af48-4a10-a851-0eeb2bb1edbf%40googlegroups.com.