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

Add `Hash#fetch_values` #776

Closed
wants to merge 1 commit into
base: trunk
from

Conversation

3 participants
@wojtekmach

wojtekmach commented Nov 30, 2014

@MaxGabriel

View changes

Show outdated Hide outdated hash.c Outdated
@timoschilling

This comment has been minimized.

Show comment
Hide comment
@timoschilling

timoschilling Dec 12, 2014

I would be great to have a fetch_values and a fetch_values!, fetch_values shouldn't raise a error and fetch_values! should do it.

timoschilling commented Dec 12, 2014

I would be great to have a fetch_values and a fetch_values!, fetch_values shouldn't raise a error and fetch_values! should do it.

@wojtekmach

This comment has been minimized.

Show comment
Hide comment
@wojtekmach

wojtekmach Dec 12, 2014

@timoschilling

Shouldn't this be h.fetch_values("cow", "bird") { |k| k.upcase } #=> ["BOVINE", "BIRD"]

no, we want to only invoke the block when the key is not present. "cow" key is present in the hash, "bird" isn't.

I would be great to have a fetch_values and a fetch_values!, fetch_values shouldn't raise a error and fetch_values! should do it.

there's already Hash#values_at that doesn't raise an error, and here fetch_values is supposed to be a companion method. See https://bugs.ruby-lang.org/issues/10017 for more information.

wojtekmach commented Dec 12, 2014

@timoschilling

Shouldn't this be h.fetch_values("cow", "bird") { |k| k.upcase } #=> ["BOVINE", "BIRD"]

no, we want to only invoke the block when the key is not present. "cow" key is present in the hash, "bird" isn't.

I would be great to have a fetch_values and a fetch_values!, fetch_values shouldn't raise a error and fetch_values! should do it.

there's already Hash#values_at that doesn't raise an error, and here fetch_values is supposed to be a companion method. See https://bugs.ruby-lang.org/issues/10017 for more information.

@wojtekmach

This comment has been minimized.

Show comment
Hide comment
@wojtekmach

wojtekmach Feb 1, 2015

@nobu any comments about this? seems there was good initial feedback about this proposal: https://bugs.ruby-lang.org/issues/10017. Please let me know what can I do to push this forward

wojtekmach commented Feb 1, 2015

@nobu any comments about this? seems there was good initial feedback about this proposal: https://bugs.ruby-lang.org/issues/10017. Please let me know what can I do to push this forward

@nobu nobu closed this in 86eaa24 Jun 12, 2015

nurse pushed a commit to nurse/ruby that referenced this pull request Sep 18, 2015

hash.c: fetch_values
* hash.c (rb_hash_fetch_values): add `Hash#fetch_values`.
  [Feature #10017] [Fix rubyGH-776]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

@wojtekmach wojtekmach deleted the wojtekmach:fetch_values branch Mar 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment