Programming Elixir page 80 about “defstruct”
I first ask question and I am a quite beginner. I followed this book again to confirm each steps’ process.
Following book by using iex, it works. But implemented IO.puts into code and did “Elixir defstruct.exs” so that it didn’t work with Error.
please help me why the error occur and how to solve this.
code:
defmodule Subscriber do
defstruct name: "", paid: false, over_18: true
end
s1 = %Subscriber{}
IO.puts inspect(s1)
Error:
** (CompileError) defstruct.exs:5: cannot access struct Subscriber, the struct was not yet defined or the struct is being accessed in the same context that defines it