Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add haskey for Vector #32898

Open
dpsanders opened this issue Aug 14, 2019 · 5 comments
Open

Add haskey for Vector #32898

dpsanders opened this issue Aug 14, 2019 · 5 comments
Labels
domain:arrays [a, r, r, a, y, s] domain:collections Data structures holding multiple items, e.g. sets kind:feature Indicates new feature / enhancement requests kind:speculative Whether the change will be implemented is speculative

Comments

@dpsanders
Copy link
Contributor

In order to write generic code that can use Vector and Dict interchangeably, it would be very useful to add haskey(v, i) for a Vector v, to check if v[i] exists.

Since there is already keys(v) for a Vector, this seems consistent.

Daniel Berge suggested on Slack to use i in keys(v), which seems to work, but also seems like an unnecessary workaround.

@yuyichao
Copy link
Contributor

#18843

@yuyichao
Copy link
Contributor

yuyichao commented Aug 14, 2019

#25105

@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 6, 2021

Should we rename isassigned to haskey?

@StefanKarpinski
Copy link
Sponsor Member

They don't answer the same question really. Vector{Any}(undef, 3) has keys 1:3 but none of those slots is assigned.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 13, 2021

Vector doesn't have haskey though, it is a Dict function, and it tests whether those keys are valid

@brenhinkeller brenhinkeller added domain:arrays [a, r, r, a, y, s] domain:collections Data structures holding multiple items, e.g. sets kind:feature Indicates new feature / enhancement requests kind:speculative Whether the change will be implemented is speculative labels Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays [a, r, r, a, y, s] domain:collections Data structures holding multiple items, e.g. sets kind:feature Indicates new feature / enhancement requests kind:speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

5 participants