I’d like to challenge that claim. ![]()
defmodule Foo do
defstruct [:foo, :bar]
@foos File.read!("lib/foos.json")
|> Jason.decode!(keys: :atoms)
|> Enum.map(&Map.put(&1, :__struct__, __MODULE__))
def list do
@foos
end
def equal? do
@foos == [%Foo{bar: 2, foo: 1}, %Foo{bar: 22, foo: 11}]
end
end
Foo.list() |> IO.inspect(label: "list()")
Foo.equal?() |> IO.inspect(label: "equal?()")
So you can’t use the struct function but that’s a small price to pay if you really want/need to do this. ![]()


















