I'm going to preface this by saying I am a total newbie in the Elixir world (and functional programming in general). I am currently learning about dictionary types, and came across structs. I defined this one, as per my book's instruction:
defmodule Subscriber do
defstruct name: "", paid: false, over_18: true
end
After that, the book works in iex for the rest of the chapter, but I wanted mine in a file. I tried to create an instance of this struct (with all values set to default) like so:
sub = %Subscriber{}
This game me a CompileError:
CompileError: cannot access struct Subscriber, the struct was not yet defined or the struct is being accessed in the same context that defines it
It works fine in iex, but like I said I would rather have it in a file. Any chance someone could explain what I'm doing wrong here?