Shortcut for pattern matching on same value-key name in Elixir map

Viewed 808

I do a fair amount of pattern matching in this style:

def action(%{start_date: start_date, amount: amount, notify: notify %}) do
  # some action
end

Most of the times, the name I choose for the parameters are the same name in the map. Is there a shortcut of specifying that pattern matching case without repeating the same name for the key and the value ?

Something in the line of this pseudo code:

def action(%{start_date: %s, amount: %s, notify: %s}) do
  IO.inspect(start_date)
  # some action
end
2 Answers
Related