# \`mergewith\` but for \`NamedTuple\`?

**URL:** https://discourse.julialang.org/t/mergewith-but-for-namedtuple/126507
**Category:** General Usage
**Tags:** question
**Created:** [March 3, 2025, 5:56pm UTC](https://discourse.julialang.org/t/mergewith-but-for-namedtuple/126507 "2025-03-03T17:56:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [March 3, 2025, 5:56pm UTC](https://discourse.julialang.org/t/mergewith-but-for-namedtuple/126507/1 "2025-03-03T17:56:34Z")

</div>

```julia
julia> a = (;x=3); b = (; x=4);

julia> a .+ b
ERROR: ArgumentError: broadcasting over dictionaries and `NamedTuple`s is reserved
Stacktrace:
 [1] broadcastable(::@NamedTuple{x::Int64})
   @ Base.Broadcast ./broadcast.jl:713
 [2] broadcasted(::typeof(+), ::@NamedTuple{x::Int64}, ::@NamedTuple{x::Int64})
   @ Base.Broadcast ./broadcast.jl:1328
 [3] top-level scope
   @ REPL[2]:1

julia> merge(a,b)
(x = 4,)

julia> mergewith(+, a,b)
ERROR: MethodError: no method matching mergewith(::typeof(+), ::@NamedTuple{x::Int64}, ::@NamedTuple{x::Int64})
The function `mergewith` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  mergewith(::Any)
   @ Base abstractdict.jl:403
  mergewith(::Any, ::AbstractDict, ::AbstractDict...)
   @ Base abstractdict.jl:401

Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

```

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [March 3, 2025, 5:59pm UTC](https://discourse.julialang.org/t/mergewith-but-for-namedtuple/126507/2 "2025-03-03T17:59:32Z")

</div>

Exactly a year… [implement mergewith(combine, ::NamedTuple, ...) by aplavin · Pull Request #53558 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/53558)
