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

New dict.map() method #13198

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

New dict.map() method #13198

wants to merge 1 commit into from

Conversation

bruchar1
Copy link
Member

@bruchar1 bruchar1 commented May 9, 2024

Dict now have a map() method that return a list of values from a given list of keys.

This new method, along with #13195, is a step toward accomplishing what is described in discussion #13189.

@bruchar1 bruchar1 requested a review from jpakkane as a code owner May 9, 2024 14:30
Dict now have a `map()` method that return a list of values from a given
list of keys.
@tristan957
Copy link
Contributor

I don't like the map name. I would rather this be called something like values(), which takes between 0 and N strings. When none are passed, return all values.

Could we augment the dict get() function to provide this functionality?

Copy link
Member

@eli-schwartz eli-schwartz left a comment

Choose a reason for hiding this comment

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

Both map and values are bad names. I found it very hard to understand the PR until I read the implementation, at which point I realized it's actually dict.get_several() or:

vals = []
foreach k, v: mydict
    if k in ['key1', 'key2']
        vals += v
    endif
endforeach

The use case feels a bit exotic, you can already do the same thing in a bit more wordy fashion, and also apparently requires finalizing another design, so IMO it's premature to implement this.

/cc @jpakkane

@jpakkane
Copy link
Member

What is the specific problem you are trying to solve with this new functionality?

@bruchar1
Copy link
Member Author

What is the specific problem you are trying to solve with this new functionality?

See #13195 and #13189.

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.

None yet

4 participants