Type Checking Structs

It’s just matching on a %StructTest, empty or not, you can’t have a struct that is empty, since a struct is just a map with pre-defined fields. You can match on an empty map though, with a guard clause, def empty(%{} = variable) when variable == %{} do , or on empty struct fields directly def empty(%StructTest{some_field: nil}) do, of course if you set a default on the field it won’t work