ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:45310] [ruby-trunk - Feature #6118][Open] Hash#keys_of(values), returns related keys of given values
@ 2012-03-06  8:55 Yui NARUSE
  2012-03-26 16:38 ` [ruby-dev:45438] [ruby-trunk - Feature #6118] " ssuda (Sambasiva Suda)
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Yui NARUSE @ 2012-03-06  8:55 UTC (permalink / raw)
  To: ruby developers list


Issue #6118 has been reported by Yui NARUSE.

----------------------------------------
Feature #6118: Hash#keys_of(values), returns related keys of given values
https://bugs.ruby-lang.org/issues/6118

Author: Yui NARUSE
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Hash#key(value) の複数版がほしいです。

{a: 1, b: 2, c: 3, d: 1}.key(1)
=> :a
というメソッドはあるのですが、
{a: 1, b: 2, c: 3, d: 1}.keys_of(1)
=> [:a, :d]
というメソッドは現状ありません。

Ruby での実装例は以下のような感じになります。
どうでしょうか。

class Hash
  def keys_of(*a)
    each_with_object([]) {|(k, v), r| r << k if a.include? v}
  end
end


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:45438] [ruby-trunk - Feature #6118] Hash#keys_of(values), returns related keys of given values
  2012-03-06  8:55 [ruby-dev:45310] [ruby-trunk - Feature #6118][Open] Hash#keys_of(values), returns related keys of given values Yui NARUSE
@ 2012-03-26 16:38 ` ssuda (Sambasiva Suda)
  2012-03-26 16:44 ` [ruby-dev:45439] " ssuda (Sambasiva Suda)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ssuda (Sambasiva Suda) @ 2012-03-26 16:38 UTC (permalink / raw)
  To: ruby developers list


Issue #6118 has been updated by ssuda (Sambasiva Suda).

File 000_ruby_hash_keys_of.patch added

Here is the implementation for Hash#keys_of
----------------------------------------
Feature #6118: Hash#keys_of(values), returns related keys of given values
https://bugs.ruby-lang.org/issues/6118#change-25194

Author: naruse (Yui NARUSE)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Hash#key(value) の複数版がほしいです。

{a: 1, b: 2, c: 3, d: 1}.key(1)
=> :a
というメソッドはあるのですが、
{a: 1, b: 2, c: 3, d: 1}.keys_of(1)
=> [:a, :d]
というメソッドは現状ありません。

Ruby での実装例は以下のような感じになります。
どうでしょうか。

class Hash
  def keys_of(*a)
    each_with_object([]) {|(k, v), r| r << k if a.include? v}
  end
end


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:45439] [ruby-trunk - Feature #6118] Hash#keys_of(values), returns related keys of given values
  2012-03-06  8:55 [ruby-dev:45310] [ruby-trunk - Feature #6118][Open] Hash#keys_of(values), returns related keys of given values Yui NARUSE
  2012-03-26 16:38 ` [ruby-dev:45438] [ruby-trunk - Feature #6118] " ssuda (Sambasiva Suda)
@ 2012-03-26 16:44 ` ssuda (Sambasiva Suda)
  2012-03-29 16:54 ` [ruby-dev:45457] [ruby-trunk - Feature #6118][Assigned] " mame (Yusuke Endoh)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ssuda (Sambasiva Suda) @ 2012-03-26 16:44 UTC (permalink / raw)
  To: ruby developers list


Issue #6118 has been updated by ssuda (Sambasiva Suda).

File 000_ruby_hash_keys_of.patch added

Here is the updated patch
----------------------------------------
Feature #6118: Hash#keys_of(values), returns related keys of given values
https://bugs.ruby-lang.org/issues/6118#change-25196

Author: naruse (Yui NARUSE)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Hash#key(value) の複数版がほしいです。

{a: 1, b: 2, c: 3, d: 1}.key(1)
=> :a
というメソッドはあるのですが、
{a: 1, b: 2, c: 3, d: 1}.keys_of(1)
=> [:a, :d]
というメソッドは現状ありません。

Ruby での実装例は以下のような感じになります。
どうでしょうか。

class Hash
  def keys_of(*a)
    each_with_object([]) {|(k, v), r| r << k if a.include? v}
  end
end


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:45457] [ruby-trunk - Feature #6118][Assigned] Hash#keys_of(values), returns related keys of given values
  2012-03-06  8:55 [ruby-dev:45310] [ruby-trunk - Feature #6118][Open] Hash#keys_of(values), returns related keys of given values Yui NARUSE
  2012-03-26 16:38 ` [ruby-dev:45438] [ruby-trunk - Feature #6118] " ssuda (Sambasiva Suda)
  2012-03-26 16:44 ` [ruby-dev:45439] " ssuda (Sambasiva Suda)
@ 2012-03-29 16:54 ` mame (Yusuke Endoh)
  2012-11-20 13:18 ` [ruby-dev:46563] [ruby-trunk - Feature #6118] " mame (Yusuke Endoh)
  2019-01-10  8:16 ` [ruby-dev:50758] [Ruby trunk Feature#6118][Feedback] " naruse
  4 siblings, 0 replies; 6+ messages in thread
From: mame (Yusuke Endoh) @ 2012-03-29 16:54 UTC (permalink / raw)
  To: ruby developers list


Issue #6118 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)


----------------------------------------
Feature #6118: Hash#keys_of(values), returns related keys of given values
https://bugs.ruby-lang.org/issues/6118#change-25399

Author: naruse (Yui NARUSE)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: 


Hash#key(value) の複数版がほしいです。

{a: 1, b: 2, c: 3, d: 1}.key(1)
=> :a
というメソッドはあるのですが、
{a: 1, b: 2, c: 3, d: 1}.keys_of(1)
=> [:a, :d]
というメソッドは現状ありません。

Ruby での実装例は以下のような感じになります。
どうでしょうか。

class Hash
  def keys_of(*a)
    each_with_object([]) {|(k, v), r| r << k if a.include? v}
  end
end


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:46563] [ruby-trunk - Feature #6118] Hash#keys_of(values), returns related keys of given values
  2012-03-06  8:55 [ruby-dev:45310] [ruby-trunk - Feature #6118][Open] Hash#keys_of(values), returns related keys of given values Yui NARUSE
                   ` (2 preceding siblings ...)
  2012-03-29 16:54 ` [ruby-dev:45457] [ruby-trunk - Feature #6118][Assigned] " mame (Yusuke Endoh)
@ 2012-11-20 13:18 ` mame (Yusuke Endoh)
  2019-01-10  8:16 ` [ruby-dev:50758] [Ruby trunk Feature#6118][Feedback] " naruse
  4 siblings, 0 replies; 6+ messages in thread
From: mame (Yusuke Endoh) @ 2012-11-20 13:18 UTC (permalink / raw)
  To: ruby developers list


Issue #6118 has been updated by mame (Yusuke Endoh).

Target version set to next minor


----------------------------------------
Feature #6118: Hash#keys_of(values), returns related keys of given values
https://bugs.ruby-lang.org/issues/6118#change-33270

Author: naruse (Yui NARUSE)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: next minor


Hash#key(value) の複数版がほしいです。

{a: 1, b: 2, c: 3, d: 1}.key(1)
=> :a
というメソッドはあるのですが、
{a: 1, b: 2, c: 3, d: 1}.keys_of(1)
=> [:a, :d]
というメソッドは現状ありません。

Ruby での実装例は以下のような感じになります。
どうでしょうか。

class Hash
  def keys_of(*a)
    each_with_object([]) {|(k, v), r| r << k if a.include? v}
  end
end


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50758] [Ruby trunk Feature#6118][Feedback] Hash#keys_of(values), returns related keys of given values
  2012-03-06  8:55 [ruby-dev:45310] [ruby-trunk - Feature #6118][Open] Hash#keys_of(values), returns related keys of given values Yui NARUSE
                   ` (3 preceding siblings ...)
  2012-11-20 13:18 ` [ruby-dev:46563] [ruby-trunk - Feature #6118] " mame (Yusuke Endoh)
@ 2019-01-10  8:16 ` naruse
  4 siblings, 0 replies; 6+ messages in thread
From: naruse @ 2019-01-10  8:16 UTC (permalink / raw)
  To: ruby-dev

Issue #6118 has been updated by naruse (Yui NARUSE).

Status changed from Assigned to Feedback

I forgot use case.

use case is welcome

----------------------------------------
Feature #6118: Hash#keys_of(values), returns related keys of given values
https://bugs.ruby-lang.org/issues/6118#change-76194

* Author: naruse (Yui NARUSE)
* Status: Feedback
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
Hash#key(value) の複数版がほしいです。

{a: 1, b: 2, c: 3, d: 1}.key(1)
=> :a
というメソッドはあるのですが、
{a: 1, b: 2, c: 3, d: 1}.keys_of(1)
=> [:a, :d]
というメソッドは現状ありません。

Ruby での実装例は以下のような感じになります。
どうでしょうか。

class Hash
  def keys_of(*a)
    each_with_object([]) {|(k, v), r| r << k if a.include? v}
  end
end

---Files--------------------------------
000_ruby_hash_keys_of.patch (2.36 KB)
000_ruby_hash_keys_of.patch (2.36 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-01-10  8:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-06  8:55 [ruby-dev:45310] [ruby-trunk - Feature #6118][Open] Hash#keys_of(values), returns related keys of given values Yui NARUSE
2012-03-26 16:38 ` [ruby-dev:45438] [ruby-trunk - Feature #6118] " ssuda (Sambasiva Suda)
2012-03-26 16:44 ` [ruby-dev:45439] " ssuda (Sambasiva Suda)
2012-03-29 16:54 ` [ruby-dev:45457] [ruby-trunk - Feature #6118][Assigned] " mame (Yusuke Endoh)
2012-11-20 13:18 ` [ruby-dev:46563] [ruby-trunk - Feature #6118] " mame (Yusuke Endoh)
2019-01-10  8:16 ` [ruby-dev:50758] [Ruby trunk Feature#6118][Feedback] " naruse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).