Hello, I asked the question earlier but have lost where I asked it - a question here sounds better though so here it is:
defmodule Inner do
defstruct prop: nil
end
defmodule Outer do
defstruct inner: %Inner{}
end
a = %Outer{inner: %Inner{prop: "Hello"}}
get_in(a, ["inner", "prop"])
Results in the error:
** (UndefinedFunctionError) function Outer.fetch/2 is undefined (Outer does not implement the Access behaviour. If you are using get_in/put_in/update_in, you can specify the field to be accessed using Access.key!/1)
Outer.fetch(%Outer{inner: %Inner{prop: "Hello"}}, "inner")
(elixir 1.15.4) lib/access.ex:305: Access.get/3
(elixir 1.15.4) lib/kernel.ex:2792: Kernel.get_in/2
#cell:5ey2h6xnqxhcq555jtahmipsngfqtwfe:1: (file)
My mental model is that structs are just sugar around maps, so why is there a behavioral difference when using get_in?