# Function arguments with multiple names

**URL:** https://discourse.julialang.org/t/function-arguments-with-multiple-names/65787
**Category:** General Usage
**Tags:** announcement, functions
**Created:** [August 4, 2021, 6:02am UTC](https://discourse.julialang.org/t/function-arguments-with-multiple-names/65787 "2021-08-04T06:02:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)
#### Post date: [August 4, 2021, 6:02am UTC](https://discourse.julialang.org/t/function-arguments-with-multiple-names/65787/1 "2021-08-04T06:02:58Z")

</div>

I’d like to use a function with multiple data sources that have slightly different parameter names.  
Is there something like

`function f(; end_date {alternates: endDate, eDate, EndDt }, start_date="1Jan2020" )`

where `end_date` is the term used within the function, endDate, eDate, EndDt are alternatives for calling the function. The function requires exactly 1 of the 4 terms to be specified

```julia
f( end_date = "1Jan2030" ) #works
f( endDate = "1Jan2030" ) #works
f( eDate = "1Jan2030" ) #works
f( EndDt = "1Jan2030" ) #works

f( ) #error end_date not specified
f( end_date = "1Jan2030", EndDt = "1Jan2030" ) #error end_date parameter specified twice.

```

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [August 4, 2021, 6:10am UTC](https://discourse.julialang.org/t/function-arguments-with-multiple-names/65787/2 "2021-08-04T06:10:17Z")

</div>

```julia
# `get_end_date` checks that exactly 1 argument is not `nothing`, and returns that 1 argument.
get_end_date(a, ::Nothing, ::Nothing, ::Nothing) = a
get_end_date(::Nothing, b, ::Nothing, ::Nothing) = b
get_end_date(::Nothing, ::Nothing, c, ::Nothing) = c
get_end_date(::Nothing, ::Nothing, ::Nothing, d) = d

# `f` is the interface function
function f(; end_date = nothing, endDate = nothing, eDate = nothing, EndDt = nothing)
    _f(get_end_date(end_date, endDate, eDate, EndDt))
end
function _f(end_date)
    ... # uses the end date
end

```

If you prefer, a more general definition of `get_end_date`:

```julia
function get_end_date(vargs::Vararg{Any,K}) where {K}
    choose = map(!isnothing, vargs)
    @assert sum(choose) == 1
    @inbounds vargs[findfirst(choose)::Int]
end

```

---

<div class="post-metadata">

### Author: ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)
#### Post date: [August 4, 2021, 9:30am UTC](https://discourse.julialang.org/t/function-arguments-with-multiple-names/65787/3 "2021-08-04T09:30:12Z")

</div>

Interesting thank you.
