diff --git a/base/tuple.jl b/base/tuple.jl index ee3174d783531..38357b3404b08 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -645,6 +645,11 @@ revargs(x, r...) = (revargs(r...)..., x) reverse(t::Tuple) = revargs(t...) +function isassigned(v::Tuple, i::Integer) + @boundscheck 1 <= i <= length(v) || return false + true +end + ## specialized reduction ## prod(x::Tuple{}) = 1 diff --git a/test/tuple.jl b/test/tuple.jl index 13af5ac992434..c55605becb730 100644 --- a/test/tuple.jl +++ b/test/tuple.jl @@ -850,3 +850,11 @@ end end end end + +@testset "isassigned" begin + t = (1, 2, 3) + @test isassigned(t, 0) === false + @test isassigned(t, 1) === true + @test isassigned(t, 3) === true + @test isassigned(t, 4) === false +end