# Map and NamedTuple

**URL:** <https://discourse.julialang.org/t/map-and-namedtuple/12814>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [August 2, 2018, 9:21am UTC](https://discourse.julialang.org/t/map-and-namedtuple/12814 "2018-08-02T09:21:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 2, 2018, 9:21am UTC](https://discourse.julialang.org/t/map-and-namedtuple/12814/1 "2018-08-02T09:21:23Z")

</div>

I really like the fact that `map` keeps the keys of `NamedTuple`, eg

```julia
julia> map(eltype, (a = [1], b = [2.0]))
(a = Int64, b = Float64)

```

but I wonder it this is something that I can rely on from now on, as I could not find it in the documentation of either `map` or `NamedTuple`.

---

<div class="post-metadata">

**Author:** ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)\
**Post date:** [August 2, 2018, 3:20pm UTC](https://discourse.julialang.org/t/map-and-namedtuple/12814/2 "2018-08-02T15:20:52Z")

</div>

Yes, this is intended and I intend to keep it this way.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 30, 2018, 12:05pm UTC](https://discourse.julialang.org/t/map-and-namedtuple/12814/3 "2018-10-30T12:05:20Z")

</div>

_(Continuing this topic with a related question instead of opening a new one)_

Occasionally it would be useful to have the keys available in `map`, in a way that meshes well with inference. I found that something like

```julia
valkeys(nt::NamedTuple{K}) where K = NamedTuple{K}(Val.(K))

```

works fine, eg in contexts like

```julia
map((k, aval, bval) -> dosomething, valkeys(a), a, b)

```

Am I missing something obvious that would achieve the same?
