# Varargs function

**URL:** https://discourse.julialang.org/t/varargs-function/60969
**Category:** General Usage
**Tags:** question
**Created:** [May 11, 2021, 5:21pm UTC](https://discourse.julialang.org/t/varargs-function/60969 "2021-05-11T17:21:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)
#### Post date: [May 11, 2021, 5:21pm UTC](https://discourse.julialang.org/t/varargs-function/60969/1 "2021-05-11T17:21:24Z")

</div>

Hi,

I have a function that takes a variable number of arguments like the following:

```julia
function view(vargs...)
  out = DataFrame(vargs)
  out
end

```

I want the ouput of `view` to be the same as if I was using `DataFrame`, example:

```julia
DataFrame(Symbol("Period") => ["T", "T-1"], Symbol("Type") => [1, 2])

```

same as

```julia
view(Symbol("Period") => ["T", "T-1"], Symbol("Type") => [1, 2])

```

I am missing an operation inside `view` to “un-vectorise” the inputs. Would you please be able to help?

Thank you

---

<div class="post-metadata">

### Author: ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)
#### Post date: [May 11, 2021, 5:26pm UTC](https://discourse.julialang.org/t/varargs-function/60969/2 "2021-05-11T17:26:05Z")

</div>

I think you want splat:

```julia
view(args...) = DataFrame(args...)

```

Note that `f([1,2,3]...) === f(1,2,3)`.

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [May 11, 2021, 5:26pm UTC](https://discourse.julialang.org/t/varargs-function/60969/3 "2021-05-11T17:26:07Z")

</div>

You’re looking for `...` 🙂

```julia
function view(vargs...)
  out = DataFrame(vargs...)
  out
end

```

`...` in a function definition “slurps” up multiple arguments, whereas it “splats” them when used in a call.

---

<div class="post-metadata">

### Author: ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)
#### Post date: [May 11, 2021, 5:26pm UTC](https://discourse.julialang.org/t/varargs-function/60969/4 "2021-05-11T17:26:45Z")

</div>

Ha, beat you to it!

---

<div class="post-metadata">

### Author: ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)
#### Post date: [May 11, 2021, 5:30pm UTC](https://discourse.julialang.org/t/varargs-function/60969/5 "2021-05-11T17:30:06Z")

</div>

Thank you guys.
