Structs are extensions built on top of maps. However, I was expecting the struct definition to be like,
defmodule User do
defstruct %{name: "John", age: 27}
end
However, I was surprised find that the fields need to be defined as Keyword Lists.
defmodule User do
defstruct [name: "John", age: 27]
end
I find this odd, is there a reason for this notation?