JuliaLang/julia

Add `haskey` for `Tuple`

Open

#35,516 opened on Apr 18, 2020

View on GitHub
 (7 comments) (2 reactions) (0 assignees)Julia (5,773 forks)batch import
collectionsgood first issue

Repository metrics

Stars
 (48,709 stars)
PR merge metrics
 (Avg merge 20d 6h) (157 merged PRs in 30d)

Description

Currently haskey is defined for NamedTuple but not for Tuple. Would it make sense to also add this for tuples? After all, keys(::Tuple) is also defined.

Code would then probably look like this

    haskey(t::Tuple, key) = isdefined(t, key)

Related: https://github.com/JuliaLang/julia/issues/32898

Contributor guide