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
Package Idea: array upsert #481
Labels
Comments
Hi Thomas, thanks for the suggestion. |
Permission to work on this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An idea for a new package: An "upsert" function for arrays. This would be based on the "upsert" operation commonly used in databases, which is a combination of "update" and "insert", however, we would adapt it to fit better for use with arrays.
You would call the function similar to this:
The idea is that you pass an array, and index that you want to "upsert" into, and the element which you want to be "upserted". If the provided index is within the bounds of the array, then the provided item will replace the item at that index. If the provided index is outside the bounds of the provided index, then it gets pushed onto the end of the array.
I can't really say for sure how much a function like this would be used/needed, I just thought I would suggest it since I had to write my own version of it for a recent project.
The text was updated successfully, but these errors were encountered: