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

array_modify: Change default value of length? #312

Closed
m-mohr opened this issue Dec 1, 2021 · 2 comments · Fixed by #421
Closed

array_modify: Change default value of length? #312

m-mohr opened this issue Dec 1, 2021 · 2 comments · Fixed by #421
Milestone

Comments

@m-mohr
Copy link
Member

m-mohr commented Dec 1, 2021

[...] I think a default length=1 is unnecessarily opinionated.

I would propose to use 0 by default, or not having a default at all

Originally posted by @soxofaan in #309 (comment)

@m-mohr
Copy link
Member Author

m-mohr commented Dec 1, 2021

[...] I couldn't find a less opinionated alternative yet assuming that the main use cases are "update" and "remove" as we also have array_append and array_concat for common insert use cases.
I don't feel like there are a lot of common use cases for inserting in-between elements, but length = 0 would mostly cater for them.
Length = null (i.e. length of values) would only really cater to the update use case and seems to make descriptions more complex. None of the examples would get less complicated, instead, we need to add the length to all of them.

Answer from #309 by @soxofaan :

I don't think that the existence of array_append and array_concat is a reason to arbitrary pick default length=1.

One could argue that default length=0 is also opinionated, but at least it is the least destructive option (any length>0 removes data)

Another defense for in favor for the length=0 default is that the most obvious default array is an empty array (length 0).

@m-mohr m-mohr modified the milestone: 1.3.0 Dec 1, 2021
@m-mohr m-mohr added this to the 2.0.0 milestone Feb 1, 2023
@m-mohr
Copy link
Member Author

m-mohr commented Mar 14, 2023

Change to length = 0

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 a pull request may close this issue.

1 participant