elixir keyword list with dynamic key
Sep 1, 2018 · 1 min read
Needed a keyword list where the key would be something I had stored in a variable. This worked nicely:
def validate_property({property, _}) do
[{property, “is not valid”}]
end
Which means, these two are equivalent:
iex(7)> [{:one,”two”}] == [one: “two”]
true