# Accessing a list of a function's keyword arguments?

**URL:** <https://discourse.julialang.org/t/accessing-a-list-of-a-functions-keyword-arguments/6215>\
**Category:** General Usage\
**Created:** [October 3, 2017, 12:07pm UTC](https://discourse.julialang.org/t/accessing-a-list-of-a-functions-keyword-arguments/6215 "2017-10-03T12:07:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlosbrody](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@carlosbrody](https://discourse.julialang.org/u/carlosbrody)\
**Post date:** [October 3, 2017, 12:07pm UTC](https://discourse.julialang.org/t/accessing-a-list-of-a-functions-keyword-arguments/6215/1 "2017-10-03T12:07:52Z")

</div>

**Can code inside function access a list of ll its keyword arguments?**

I am writing a function with multiple keyword arguments, and I want to check the type of each of the arguments. An example might be something like

```
function tester(; a=1, b=2, c=3)
    if typeof(a)<:Float64 || typeof(b)<:Float64 || typeof(c)<:Float64
        @printf("I found a Float64\n")
    end
    # Then other code following after that
end

```

But that approach means that if I add a new keyword argument to the argument list, I also have to remember to add it to the set of checked arguments. What I would really like to do is have some way to access all the keyword arguments, as in

```
function tester(; a=1, b=2, c=3)
    my_kw_args = SOME_METHOD_THAT_RETURNS_THIS_FUNCTIONS_KW_ARGS()

    if any(map(k -> typeof(my_kw_args[k])==Float64, keys(my_kw_args)))
        @printf("I found a Float64\n")
    end
    # Then other code following after that
end

```

And this why I am asking: _is there some way, inside a function, to access a list of all of the function’s keyword arguments?_

Thanks in advance for any help or suggestions!!

(p.s. I know I could instead write my function as

```
function tester(; kwargs...)

```

but that is itself inconvenient. Having the values already assigned to variables, as with the usual a=default formulation, is really great.)

---

<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 3, 2017, 12:22pm UTC](https://discourse.julialang.org/t/accessing-a-list-of-a-functions-keyword-arguments/6215/2 "2017-10-03T12:22:15Z")

</div>

A common solution is to define a structure that contains the relevant information, and pass that around. See eg `Options(...)` in `Optim.jl`.
