Splat tuple to new in struct


#1

I have a struct with an inner constructor, which calls the function “name_comparison”. I would like to splat the tuple that name_comparison returns as the arguments for the function “new”. However I get the following error “ERROR: syntax: … is not supported inside “new””. Is there some other way to do this?

struct Product
    name::String
    variants::Array{String}
    name_elements::Array{String}
    variant_elements::Array{String}

    function Product(name::String, variants::Array{String})
        new(name_comparison(name, variants)...)
    end
end

#2
struct Product
    name::String
    variants::Array{String}
    name_elements::Array{String}
    variant_elements::Array{String}

    function Product(name::String, variants::Array{String})
        a, b, c, d = name_comparison(name, variants)
        new(a, b, c, d)
    end
end