# Here's a fun thing

**URL:** <https://discourse.julialang.org/t/heres-a-fun-thing/106556>\
**Category:** General Usage\
**Created:** [November 22, 2023, 2:24am UTC](https://discourse.julialang.org/t/heres-a-fun-thing/106556 "2023-11-22T02:24:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bertschi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bertschi/32/33462_2.png) [@bertschi](https://discourse.julialang.org/u/bertschi)\
**Post date:** [November 22, 2023, 9:38pm UTC](https://discourse.julialang.org/t/heres-a-fun-thing/106556/2 "2023-11-22T21:38:58Z")

</div>

Looping is fine in Julia, so no need to replace it by recursion. One could use broadcasting and dispatch (hiding the if) though:

```julia
updatekeys(f, v) = v # Base case, i.e., leave atomic `v` alone
updatekeys(f, v::AbstractDict) = Dict(zip(f.(keys(v)),
                                          updatekeys.(Ref(f), values(v))))

```

```julia
# Works just like your dict_key_to_symbol_v2
updatekeys(Symbol, d3lvl)

```

---

_[View the full topic](https://discourse.julialang.org/t/heres-a-fun-thing/106556)._
