How best to detect if a passed-in tuple is
(a1, a2)
or
((a1, a2), (b1, b2))
How best to detect if a passed-in tuple is
(a1, a2)
or
((a1, a2), (b1, b2))
julia> ((1, 2), ("foo", :bar)) isa Tuple{Tuple{Any,Any}, Tuple{Any,Any}}
true
Thanks for the response.
I hope being able to detect (a1, a2) because the tuple of tuples is variable length.
But this dones’t work:
julia> (1,2) isa Tuple{Any,Any}
true
julia> ((1,2), (2,3)) isa Tuple{Any,Any}
true
julia> detect(v::Tuple{Any,Any}) = !(v[1] isa Tuple && v[2] isa Tuple)
detect (generic function with 1 method)
julia> detect(v) = false
detect (generic function with 2 methods)
julia> detect((1, 2))
true
julia> detect(((1, 2), (3, 4)))
false