# Export enum

**URL:** <https://discourse.julialang.org/t/export-enum/5396>\
**Category:** General Usage\
**Tags:** enum\
**Created:** [August 15, 2017, 8:29pm UTC](https://discourse.julialang.org/t/export-enum/5396 "2017-08-15T20:29:31Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mathieu17g](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mathieu17g/32/34938_2.png) [@mathieu17g](https://discourse.julialang.org/u/mathieu17g)\
**Post date:** [November 11, 2021, 8:26am UTC](https://discourse.julialang.org/t/export-enum/5396/4 "2021-11-11T08:26:31Z")

</div>

In order to deal with the case where you specify the value of each instances, you may use:

```julia
julia> module A
           macro exported_enum(T, syms...)
               return esc(quote
                   @enum($T, $(syms...))
                   export $T
                   for inst in Symbol.(instances($T))
                       eval($(Expr(:quote, :(export $(Expr(:$, :inst))))))
                   end
               end)
           end
           @exported_enum fruit apple=2 banana=3
       end
Main.A

julia> using Main.A

julia> fruit
Enum fruit:
apple = 2
banana = 3

```

---

_[View the full topic](https://discourse.julialang.org/t/export-enum/5396)._
