# Understanding splat operator in return statement

**URL:** <https://discourse.julialang.org/t/understanding-splat-operator-in-return-statement/65110>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 22, 2021, 2:19pm UTC](https://discourse.julialang.org/t/understanding-splat-operator-in-return-statement/65110 "2021-07-22T14:19:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VLucet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlucet/32/27421_2.png) [@VLucet](https://discourse.julialang.org/u/VLucet)\
**Post date:** [July 22, 2021, 2:19pm UTC](https://discourse.julialang.org/t/understanding-splat-operator-in-return-statement/65110/1 "2021-07-22T14:19:22Z")

</div>

Hi, I followed the **DataFrames.jl** workshop earlier this week at JuliaCon, and it was my first time using DataFrames in Julia, hence why I am posting in First Steps.

I was able to follow until the last part of the worshop when an example of bootstrapping was shown. The function below computes a probit model on a dataframe and is called on bootstrapped dataframes.

I am having a hard time understading the return statement. I was hoping someone could walk me through all that is happening on that line, especially what happens with the splat … operator and the semi colon.

```julia
function boot_sample(df)
    df_boot = df[rand(1:nrow(df), nrow(df)), :]
    probit_boot = glm(@formula(lfp ~ lnnlinc + age + age^2 + educ + nyc + noc + foreign),
                      df_boot, Binomial(), ProbitLink())
    return (; (Symbol.(coefnames(probit_boot)) .=> coef(probit_boot))...)
end

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [July 22, 2021, 2:26pm UTC](https://discourse.julialang.org/t/understanding-splat-operator-in-return-statement/65110/2 "2021-07-22T14:26:00Z")

</div>

1. `coefnames(probit_boot)` returns a `Vector` of `String`s corresponding to `"lnnlinc"`, `"age"`, etc.
2. `Symbol.(coefnames(probit_boot))` casts these strings as `Symbol`s, which is necessary because it uses the `(; ags...)` constructor for a `NamedTuple`.
3. In Julia, a `NamedTuple` is _kind of_ like a dictionary, in that it can be used to look up objects based on a `Symbol`. The syntax `(; :a => 1, :b => 2)` can be used to create the named tuple `(a = 1, b = 2)`. Using `=>` instead of `=` means you can construct named tuples programmatically, i.e. not writing out the literal `a` but rather using something like `a_sym = :a; (; a_sym => 1)`.

---

<div class="post-metadata">

**Author:** ![VLucet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlucet/32/27421_2.png) [@VLucet](https://discourse.julialang.org/u/VLucet)\
**Post date:** [July 22, 2021, 2:29pm UTC](https://discourse.julialang.org/t/understanding-splat-operator-in-return-statement/65110/3 "2021-07-22T14:29:04Z")

</div>

Thanks, Peter, this is exactly what I needed. I was unaware of the named tuple constructor with the semi colon. Very elegant!
