# Converting String to Symbol during struct construction

**URL:** <https://discourse.julialang.org/t/converting-string-to-symbol-during-struct-construction/75031>\
**Category:** General Usage\
**Tags:** struct, constructors\
**Created:** [January 22, 2022, 12:20pm UTC](https://discourse.julialang.org/t/converting-string-to-symbol-during-struct-construction/75031 "2022-01-22T12:20:33Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [January 22, 2022, 1:40pm UTC](https://discourse.julialang.org/t/converting-string-to-symbol-during-struct-construction/75031/6 "2022-01-22T13:40:59Z")

</div>

> [@sstroemer](#):
>
> Consider the following change, that breaks it again:

Maybe this helps then

```julia
Base.@kwdef mutable struct MyStruct
    id::Int
    value::Symbol = :fixed
    notimportant::Int = -1
    function MyStruct(id, value, notimportant)
        new(id, Symbol(value), notimportant)
    end
end

MyStruct(id=1, value=:a)       
MyStruct(id=2, value="b")      

```

---

_[View the full topic](https://discourse.julialang.org/t/converting-string-to-symbol-during-struct-construction/75031)._
