#m.a vs m[:a]
5 messages · Page 1 of 1 (latest)
5 messages · Page 1 of 1 (latest)
What is the difference between these two ways of accessing elements of a map? I thought they were equivalent, but:
iex(11)> quote do: m[:a]
{{:., [], [Access, :get]}, [], [{:m, [], Elixir}, :a]}
iex(12)> quote do: m.a
{{:., [], [{:m, [], Elixir}, :a]}, [no_parens: true], []}
Thankyou! So is Map.get(m, :a) equivalent to m[:a]?
it'll work the same for maps but it's not the same