I did:
julia> ntup = (1, 2, 3, 4, 5, 6), NTuple{6, Int}
julia> Set(ntup)
Set(Any[(1, 2, 3, 4, 5, 6), NTuple{6,Int64}])
But I want to get a set of Int64.
How can I achieve that?
I did:
julia> ntup = (1, 2, 3, 4, 5, 6), NTuple{6, Int}
julia> Set(ntup)
Set(Any[(1, 2, 3, 4, 5, 6), NTuple{6,Int64}])
But I want to get a set of Int64.
How can I achieve that?
Your first line isn’t doing what you probably think it’s doing. It creates a tuple of length 2 where the first item is a tuple of 6 integers and the second item is the Type
NTuple{6,Int}
. So of course, the Set
constructor which simply takes an iterable constructs a Set
with the two items in your outer tuple. Set((1,2,3,4,5,6))
works exactly as expected. If you’re getting the length 2 tuple from somewhere else, Set(first(ntup))
works as expected.
If you would like to assert that the type of ntup
is NTuple{6,Int}
, the syntax you’re looking for is ntup::NTuple{6,Int} = (1,2,3,4,5,)
.
Thank you!