View Source Working with structs
setup
Setup
Mix.install([
{:type_checker, "~> 0.1.1"}
])
checking-the-type-of-structs
Checking the type of structs
For this example, we will model a person (having only one attribute - name).
defmodule Person do
defstruct name: :string
end
Now that we have our struct defined, we can go ahead and create a new person.
v1 = %Person{name: "John Smith"}
Use type checker's which?
function to get the variable's type.
TypeChecker.which?(v1)