# How does \`kwargs...\` pass into another function?

**URL:** <https://discourse.julialang.org/t/how-does-kwargs-pass-into-another-function/78976>\
**Category:** General Usage\
**Created:** [April 4, 2022, 2:51am UTC](https://discourse.julialang.org/t/how-does-kwargs-pass-into-another-function/78976 "2022-04-04T02:51:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zengfung](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zengfung/32/28958_2.png) [@zengfung](https://discourse.julialang.org/u/zengfung)\
**Post date:** [April 4, 2022, 2:51am UTC](https://discourse.julialang.org/t/how-does-kwargs-pass-into-another-function/78976/1 "2022-04-04T02:51:42Z")

</div>

Hi all,

I’m trying to understand the parsing of keyword arguments in Julia functions. In the following code snippet, I created `foo1()` which takes in 2 keyword arguments, and `bar1()` which takes in keyword arguments to pass into `foo1()`.

```julia
julia> function foo1(;a=1,b=2)
           println("$a $b")
       end
foo1 (generic function with 1 method)

julia> function bar1(;kwargs...)
           foo1(kwargs...)
       end
bar1 (generic function with 1 method)

julia> bar1()
1 2

julia> foo1(a=2) # No issues here
2 2

```

But now I’m facing issues trying to modify arguments in `foo1` through `bar1`. How do I fix this?

Note: I’m currently using Julia v1.7.2.

```julia
julia> bar1(a=2) # same error with bar1(;a=2)
ERROR: MethodError: no method matching foo1(::Pair{Symbol, Int64})
Closest candidates are:
  foo1(; a, b) at REPL[36]:1
Stacktrace:
 [1] bar1(; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:a,), Tuple{Int64}}})
   @ Main .\REPL[37]:2
 [2] top-level scope
   @ REPL[39]:1

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [April 4, 2022, 3:30am UTC](https://discourse.julialang.org/t/how-does-kwargs-pass-into-another-function/78976/2 "2022-04-04T03:30:08Z")

</div>

It’s easy to miss, but you’re actually unpacking the keyword arguments into `foo1` as positional arguments. You’ll need a `;` in there to let Julia know that you’re unpacking into the keyword arguments:

```julia
function bar1(; kwargs...)
    foo1(; kwargs...)
end

```
