# Using a struct within a struct produces errors

**URL:** <https://forum.elixirforum.com/t/using-a-struct-within-a-struct-produces-errors/71058>\
**Category:** Questions\
**Tags:** data-structures, troubleshooting, learning-elixir, help\
**Created:** [May 29, 2025, 6:39pm UTC](https://forum.elixirforum.com/t/using-a-struct-within-a-struct-produces-errors/71058 "2025-05-29T18:39:16Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![sodapopcan](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/32/34668_2.png) [@sodapopcan](https://forum.elixirforum.com/u/sodapopcan)\
**Post date:** [May 29, 2025, 8:00pm UTC](https://forum.elixirforum.com/t/using-a-struct-within-a-struct-produces-errors/71058/9 "2025-05-29T20:00:13Z")

</div>

That goes back to what Greg was saying that structs are named after the module itself. This is no different than if you want to use a module within itself: you either have to use ` __MODULE__ ` or you can type the full name verbatim.

As I said in my previous answer, `Foo.Bar` and `Foo` are _completely different modules_. It sounds like you are still thinking of it as `Bar` is a module within `Foo`. This is not the case, they are totally independent. Just think of `.` as an underscore. The `.` between the module name and the function, however, _is_ an operator, though. It’s separating module and function name.

Sorry for the all the edits but I perhaps it’s clearer to say that the `Foo` in `Foo` and the `Foo` in `Foo.Bar` also have absolutely no relation.

---

_[View the full topic](https://forum.elixirforum.com/t/using-a-struct-within-a-struct-produces-errors/71058)._
