# Generalizing functions to accept inputs with 1 or 2 (or with 2 or 3) dimensions

**URL:** <https://discourse.julialang.org/t/generalizing-functions-to-accept-inputs-with-1-or-2-or-with-2-or-3-dimensions/49317>\
**Category:** New to Julia\
**Tags:** function\
**Created:** [October 30, 2020, 4:59pm UTC](https://discourse.julialang.org/t/generalizing-functions-to-accept-inputs-with-1-or-2-or-with-2-or-3-dimensions/49317 "2020-10-30T16:59:53Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 31, 2020, 9:59am UTC](https://discourse.julialang.org/t/generalizing-functions-to-accept-inputs-with-1-or-2-or-with-2-or-3-dimensions/49317/21 "2020-10-31T09:59:49Z")

</div>

That seems to work with keyword arguments just fine:

```julia
julia> f(x,y...;z=3) = println(x,y,z)
f (generic function with 1 method)

julia> f(1,2,3,z=4)
1(2, 3)4

```

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [October 31, 2020, 3:36pm UTC](https://discourse.julialang.org/t/generalizing-functions-to-accept-inputs-with-1-or-2-or-with-2-or-3-dimensions/49317/22 "2020-10-31T15:36:41Z")

</div>

I meant an [optional positional argument](https://docs.julialang.org/en/v1/manual/functions/#Optional-Arguments), but switching to a keyword argument is easy enough.

[Previous page](https://discourse.julialang.org/t/generalizing-functions-to-accept-inputs-with-1-or-2-or-with-2-or-3-dimensions/49317.md?page=1)
