-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
New implementation of dict.update
#659
Conversation
dict.update
I think this function should be called change. I think the other implementation already done should be called update https://github.com/gleam-lang/stdlib/pull/610/files. Update means that there already is something and it can fail to update. Update does not signal removal. Change signals removal. Change fits to this PR, update to the other. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
@lpil are you certain about this being named update rather than change? |
What's the motivation for it being change. I thought we did the whole deprecation cycle to free up the name update? |
|
test/gleam/dict_test.gleam
Outdated
// Utilize a function returning a `Result` in the change function. | ||
let half_or_zero_else_noop = fn(x) { | ||
case x { | ||
Some(i) -> int.divide(i, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because other functions usually return Result
rather than Option
, I have opted for the change function to return Result
not Option
as well.
I have added a unit test example to show what I mean.
Are you certain you want to return Option
instead?
ref #659 (comment) cc @lpil
After feedback I made the changes to return Option rather than Result and tried to simplify the docs and the unit tests |
This is still ready to be reviewed/merged unless you want me to rename this to change and have update do the other impl (see above). Please let me know if there are still things to do. |
Any chance to get this into 0.42 with either name |
I have removed conflicts with recent changes on main branch @lpil any news on this PR? I am hoping for one of these:
|
dict.update
dict.update
f3d7e38
to
4bab4b7
Compare
4bab4b7
to
1959ea6
Compare
I have resolved the merge conflicts another time. Is this desired (as update() or as change())? |
Hello! Thank you for this but I've not yet had any reports of real applications feeling they need this yet so I would like to wait until that demand is clear. |
OK, someone in future can implement it as change() (or update()) if demand is noticed. |
Replaces #610