# Destructuring syntax in julia 1.7

**URL:** <https://discourse.julialang.org/t/destructuring-syntax-in-julia-1-7/68236>\
**Category:** Internals & Design\
**Tags:** destructuring\
**Created:** [September 15, 2021, 11:01pm UTC](https://discourse.julialang.org/t/destructuring-syntax-in-julia-1-7/68236 "2021-09-15T23:01:36Z")\
**Posts on this page:** 1\
**Showing post:** 56

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [October 18, 2022, 2:01am UTC](https://discourse.julialang.org/t/destructuring-syntax-in-julia-1-7/68236/56 "2022-10-18T02:01:50Z")

</div>

Wanted to destructure a dictionary, found this convenient:

```julia
mydict = Dict(:x=>1, :y=>2, :z=>3)
(; x, y) = NamedTuple(mydict)

```

Unfortunately it works only for dictionaries whose keys are symbols, `Dict{Symbol, T}`. It doesn’t work for a dictionary whose keys are strings `Dict{String, T}` (as is frequently the case for config files, etc.).

This can be addressed by overloading `NamedTuple` to convert string keys to symbols:

```julia
NamedTuple(d::Dict{String,T} where T) = NamedTuple{Tuple(Symbol(k) for k ∈ keys(d))}(v for v ∈ values(d))

```

---

_[View the full topic](https://discourse.julialang.org/t/destructuring-syntax-in-julia-1-7/68236)._
