# Type Checking Structs

**URL:** <https://forum.elixirforum.com/t/type-checking-structs/729>\
**Category:** Questions\
**Tags:** data-structures\
**Created:** [May 27, 2016, 11:00am UTC](https://forum.elixirforum.com/t/type-checking-structs/729 "2016-05-27T11:00:27Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![amnu3387](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@amnu3387](https://forum.elixirforum.com/u/amnu3387)\
**Post date:** [January 17, 2018, 1:40pm UTC](https://forum.elixirforum.com/t/type-checking-structs/729/10 "2018-01-17T13:40:18Z")

</div>

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

---

_[View the full topic](https://forum.elixirforum.com/t/type-checking-structs/729)._
