# Hide default constructor for a struct

**URL:** <https://discourse.julialang.org/t/hide-default-constructor-for-a-struct/89064>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 21, 2022, 2:08pm UTC](https://discourse.julialang.org/t/hide-default-constructor-for-a-struct/89064 "2022-10-21T14:08:42Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [December 20, 2023, 8:15pm UTC](https://discourse.julialang.org/t/hide-default-constructor-for-a-struct/89064/11 "2023-12-20T20:15:19Z")

</div>

Not a bug. The struct has local scope and you can evaluate arbitrary code inside to define ways to construct objects of the type. The most common way to do this is to add methods to the type object itself, but you can do other things as well, eg define a single globally bound instance or a global function by another name that constructs them. If there is any code in a strict you don’t get a default constructor.

---

_[View the full topic](https://discourse.julialang.org/t/hide-default-constructor-for-a-struct/89064)._
