Skip to content

Conversation

eksperimental
Copy link
Contributor

@eksperimental eksperimental commented Jul 22, 2020

  • It removes the concept of the "get" value (which should have been "gotten" IMO).
  • Renames "initial" argument to "default"
  • Makes use of the concept of "current value" which was already present in some functions, and uses this in the examples and the specs consistently

@eksperimental eksperimental force-pushed the map_get_and_update_specs branch from d5417f3 to e571ddb Compare July 22, 2020 19:04
* It removes the concept of the "get" value (which should have been "gotten" IMO).
* Renames "initial" argument to "default"
* Makes use of the concept of "current value" which was already present in some functions, and uses this in the examples and the specs consistently
%{a: 2}
iex> Map.update(%{a: 1}, :b, 11, &(&1 * 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely prefer existing_value, as it makes it clear it won't be called if there is no value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! they are really good names for stressing the distinction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected

@@ -845,7 +845,9 @@ defmodule Map do
{nil, %{a: 1}}

"""
@spec get_and_update(map, key, (value -> {get, value} | :pop)) :: {get, map} when get: term
@spec get_and_update(map, key, (value -> {current_value, new_value :: value} | :pop)) ::
{current_value, map}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for current_value here, as it is also called if the value is nil. I also like new_value!

@josevalim josevalim merged commit c1a538e into elixir-lang:master Jul 23, 2020
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@eksperimental eksperimental deleted the map_get_and_update_specs branch July 23, 2020 14:24
eksperimental added a commit to eksperimental-forks/elixir that referenced this pull request Jul 23, 2020
Inspired by c1a538e (elixir-lang#10223)

* Fixes the spec of Keyword.get_and_update!/3 that was missing the :pop return value for the update function
* It removes the concept of the "get" value and replaced it consistently with "current value"
* Renames "initial" argument to "default"
* Uses "existing value" when applicable
josevalim pushed a commit that referenced this pull request Jul 23, 2020
Inspired by c1a538e (#10223)

* Fixes the spec of Keyword.get_and_update!/3 that was missing the :pop return value for the update function
* It removes the concept of the "get" value and replaced it consistently with "current value"
* Renames "initial" argument to "default"
* Uses "existing value" when applicable
eksperimental added a commit to eksperimental-forks/elixir that referenced this pull request Jul 27, 2020
josevalim pushed a commit that referenced this pull request Jul 27, 2020
To be consistent with recently introduced changes: #10228, #10223
eksperimental added a commit to eksperimental-forks/elixir that referenced this pull request Mar 27, 2021
In the same fashion of PRs elixir-lang#10228 and elixir-lang#10223

Replaces:
- `get_values` with `current_value`
- `update_value` with `new_value`
- `data` with `new_data` when suitable

Adds nil as an argument term in the function spec.
josevalim pushed a commit that referenced this pull request Mar 27, 2021
In the same fashion of PRs #10228 and #10223

Replaces:
- `get_values` with `current_value`
- `update_value` with `new_value`
- `data` with `new_data` when suitable

Adds nil as an argument term in the function spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants