Splatting, tuples, vectors

I have the following MWE:

struct PlotX
    X
    Y
end

function test(X, Y...)
    len=length(Y)
    println(len)
    println(typeof(Y))
    PlotX(X, Y)
end

T = 0:0.1:2pi
X = sin.(T)
Y = cos.(T)
p1 = test(T, X, Y);
p2 = test(p1.X, p1.Y);
nothing

Output:

2
Tuple{Vector{Float64}, Vector{Float64}}
1
Tuple{Tuple{Vector{Float64}, Vector{Float64}}}

What I want to achieve is to use the struct p1 and call the function test such that the second call has the same result as the first call.

How can I avoid to get a Tuple{Tuple{Vector{Float64}, Vector{Float64}}} and get a Tuple{Vector{Float64}, Vector{Float64}} in the second call instead?

This line needs to be test(p1.X, p1.Y...)

1 Like

Do you mean “splatting”?

1 Like