# Passing keyword varargs into a function as an iterable input

**URL:** <https://discourse.julialang.org/t/passing-keyword-varargs-into-a-function-as-an-iterable-input/16776>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [October 25, 2018, 6:56am UTC](https://discourse.julialang.org/t/passing-keyword-varargs-into-a-function-as-an-iterable-input/16776 "2018-10-25T06:56:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmetumutdurmus](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@ahmetumutdurmus](https://discourse.julialang.org/u/ahmetumutdurmus)\
**Post date:** [October 25, 2018, 6:56am UTC](https://discourse.julialang.org/t/passing-keyword-varargs-into-a-function-as-an-iterable-input/16776/1 "2018-10-25T06:56:54Z")

</div>

I have a function that accepts varargs as keyword arguments. Namely:  
`function Foo(x; kw...) some calculations vs... end`

When I pass on the keyword arguments explicitly I get the desired result.  
That is if I explicitly write:  
`Foo(SomeInput, Argument1 = (SomeTupleElement, SomeTupleElement), Argument2 = (SomeTupleElement, SomeTupleElement)`  
I get the desired result.  
Yet I want to put my keyword varargs into a collection (an array, a vector, a tuple, a named tuple, a pair, anything really) and pass that collection as argument to `Foo`.  
That is I wish to be able to create some object `MyKeywordVarargs` and write `Foo(SomeInput, MyKeywordVarargs)` and still obtain the same results.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [October 25, 2018, 7:03am UTC](https://discourse.julialang.org/t/passing-keyword-varargs-into-a-function-as-an-iterable-input/16776/2 "2018-10-25T07:03:29Z")

</div>

Like so:

```julia
julia> f(;kw...) = kw                                                                                                                                                   
f (generic function with 1 method)                                                                                                                                      

julia> f(;(a=1, b=2)...)                                                                                                                                                
pairs(::NamedTuple) with 2 entries:                                                                                                                                     
  :a => 1                                                                                                                                                               
  :b => 2                                                                                                                                                               

```

---

<div class="post-metadata">

**Author:** ![ahmetumutdurmus](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@ahmetumutdurmus](https://discourse.julialang.org/u/ahmetumutdurmus)\
**Post date:** [October 25, 2018, 7:34am UTC](https://discourse.julialang.org/t/passing-keyword-varargs-into-a-function-as-an-iterable-input/16776/3 "2018-10-25T07:34:32Z")

</div>

Thanks a lot for your help.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [October 25, 2018, 8:25am UTC](https://discourse.julialang.org/t/passing-keyword-varargs-into-a-function-as-an-iterable-input/16776/4 "2018-10-25T08:25:27Z")

</div>

You’re welcome. You should be able to mark this question as solved (saves other people also looking at this).
