# Parametric constructor, promotion and splatting (...)

**URL:** <https://discourse.julialang.org/t/parametric-constructor-promotion-and-splatting/52066>\
**Category:** New to Julia\
**Created:** [December 18, 2020, 7:27pm UTC](https://discourse.julialang.org/t/parametric-constructor-promotion-and-splatting/52066 "2020-12-18T19:27:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mocalvao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mocalvao/32/19318_2.png) [@mocalvao](https://discourse.julialang.org/u/mocalvao)\
**Post date:** [December 18, 2020, 7:27pm UTC](https://discourse.julialang.org/t/parametric-constructor-promotion-and-splatting/52066/1 "2020-12-18T19:27:30Z")

</div>

Hi there,

I am reading the page [ParametricConstructors](https://docs.julialang.org/en/v1/manual/constructors/#Parametric-Constructors) of the manual, where a `struct` Point is defined as:

```julia
struct Point{T<:Real}
           x::T
           y::T
           Point{T}(x,y) where {T<:Real} = new(x,y)
       end

```

and then the following constructor is presented:

```julia
Point(x::Real, y::Real) = Point(promote(x,y)...)

```

I am particularly intrigued with the use of the splatting operator (…) rigtht after the promote(x,y) call. In this very same example it seems unnecessary, since there are exactly two arguments for Point in the left-hand side as well for promote in the right-hand side. Is this really the case here? If so, I wonder about a specific example, in another context, where the use of the splatting operator would make sense or, perhaps, be unavoidable.

Thanks

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [December 18, 2020, 10:52pm UTC](https://discourse.julialang.org/t/parametric-constructor-promotion-and-splatting/52066/2 "2020-12-18T22:52:19Z")

</div>

`promote(x, y)` returns a tuple, while the `Point` constructor excepts two separate arguments. Consider if instead of a `Point`, I tried to promote two things and place them in a vector:

```julia
julia> promote(1.0, 2)
(1.0, 2.0)

julia> [promote(1.0, 2)]
1-element Array{Tuple{Float64,Float64},1}:
 (1.0, 2.0)

julia> [promote(1.0, 2)...]
2-element Array{Float64,1}:
 1.0
 2.0

```

Splatting “unpacks” the iterator, making the call treat each element as separate argument.

> [@mocalvao](#):
>
> where the use of the splatting operator would make sense or, perhaps, be unavoidable.

This is precisely such a case 😉
