# How to get the individual element of a defined enum type?

**URL:** https://discourse.julialang.org/t/how-to-get-the-individual-element-of-a-defined-enum-type/19878
**Category:** General Usage
**Created:** [January 21, 2019, 3:25pm UTC](https://discourse.julialang.org/t/how-to-get-the-individual-element-of-a-defined-enum-type/19878 "2019-01-21T15:25:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)
#### Post date: [January 21, 2019, 3:25pm UTC](https://discourse.julialang.org/t/how-to-get-the-individual-element-of-a-defined-enum-type/19878/1 "2019-01-21T15:25:08Z")

</div>

This should be a rather simple question. The following is the code:

```julia
Starting Julia...
               _
   _ _ _(_)_ | A fresh approach to technical computing
  (_) | (_) (_) | Documentation: https://docs.julialang.org
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 0.7.0 (2018-08-08 06:46 UTC)
 _/ |\ __'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu

julia> @enum Priority n h m l

julia> Priority(0)
n::Priority = 0

julia> String(Priority(0))
ERROR: MethodError: Cannot `convert` an object of type Priority to an object of type String
Closest candidates are:
  convert(::Type{String}, ::Symbol) at deprecated.jl:53
  convert(::Type{String}, ::Array{UInt8,1}) at deprecated.jl:53
  convert(::Type{String}, ::AbstractArray{Char,1}) at deprecated.jl:53
  ...
Stacktrace:
 [1] String(::Priority) at ./deprecated.jl:473
 [2] top-level scope at none:0

julia> Int(Priority(0))
0

julia> typeof(n)
Enum Priority:
n = 0
h = 1
m = 2
l = 3

```

My question is, as you can see from the above, how to get the String counterpart of the Priority type? This should be doable easily, right? Did I miss something?

---

<div class="post-metadata">

### Author: ![yurivish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yurivish/32/307_2.png) [@yurivish](https://discourse.julialang.org/u/yurivish)
#### Post date: [January 21, 2019, 3:47pm UTC](https://discourse.julialang.org/t/how-to-get-the-individual-element-of-a-defined-enum-type/19878/2 "2019-01-21T15:47:15Z")

</div>

> [@bsnyh](#):
>
> Priority(0)

Lowecase `string` is a different and more flexible function than `String`, which is the `String` constructor, and can convert most values to strings:

```julia
julia> string(Priority(0))
"n"

```

It is curious that there is an `Int` constructor for Enums but no `String` constructor.
