# Map does not work with pairs(::NamedTuple)

**URL:** https://discourse.julialang.org/t/map-does-not-work-with-pairs-namedtuple/20223
**Category:** Internals & Design
**Tags:** question
**Created:** [January 29, 2019, 10:05am UTC](https://discourse.julialang.org/t/map-does-not-work-with-pairs-namedtuple/20223 "2019-01-29T10:05:27Z")
**Posts on this page:** 2
**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: [January 29, 2019, 10:05am UTC](https://discourse.julialang.org/t/map-does-not-work-with-pairs-namedtuple/20223/1 "2019-01-29T10:05:27Z")

</div>

Is this a bug? I somehow expected it to work. At least the error message could be improved (as no dictionaries are involved at any point). Should I open an issue?

```julia
julia> VERSION
v"1.2.0-DEV.219"

julia> nt = (a = 1, b = 2)
(a = 1, b = 2)

julia> map(((n, v),) -> "$n is $v", pairs(nt))
ERROR: map is not defined on dictionaries
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] map(::Function, ::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol,Symbol},NamedTuple{(:a, :b),Tuple{Int64,Int64}}}) at ./abstractarray.jl:2049
 [3] top-level scope at REPL[175]:1

# cf collecting before iteration
julia> map(((n, v),) -> "$n is $v", collect(pairs(nt)))
2-element Array{String,1}:
 "a is 1"
 "b is 2"

```

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [January 29, 2019, 12:26pm UTC](https://discourse.julialang.org/t/map-does-not-work-with-pairs-namedtuple/20223/2 "2019-01-29T12:26:08Z")

</div>

```julia
isa(pairs(nt), AbstractDict)

```

is `true`. The word in the message, “dictionaries”, is perhaps vague. Does it refer to `AbstractDict` and subtypes ?
