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

Make isassigned work with tuples #30028

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

perrutquist
Copy link
Contributor

This PR adds a method isassigned(v::Tuple, i::Integer) which makes that function work on Tuples in exactly the same way that it does on Vectors. (Since a Tuple cannot be created without being assigned, all that is left is to check that the index is within bounds.)

This makes it easier to write generic code that works on both Vectors and Tuples.

@StefanKarpinski
Copy link
Member

If this is going to work, this is how it needs to work but I'm just wondering if this is a good idea for tuples. Requesting @JeffBezanson's input on the design aspect...

@oscardssmith
Copy link
Member

seems reasonable to me... Let's see if I can rebase this 5 years and have it still pass tests :)

This commit adds a method `isassigned(v::Tuple, i::Integer)` which makes
that function work on `Tuple`s, the same way it does on `Vector`s.
(Since a `Tuple` cannot be created without being assigned, all that
is left is to check that the index is within bounds.)

This makes it easier to write generic code that works on both
`Vector`s and `Tuple`s.
@JeffBezanson
Copy link
Member

🤷 Might as well I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants