https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782013-02-07T17:59:09ZRuby Issue Tracking SystemRuby master - Feature #7796: Hash#keys should return a sethttps://bugs.ruby-lang.org/issues/7796?journal_id=359702013-02-07T17:59:09Zphluid61 (Matthew Kerwin)matthew@kerwin.net.au
<ul></ul><p>On 7 February 2013 17:52, alexeymuranov (Alexey Muranov) <<br>
<a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a>> wrote:</p>
<blockquote>
<p>=begin<br>
In my opinion, (({Hash#keys})) should return an instance of (({Set})).<br>
=end</p>
</blockquote>
<p>Is this related to an earlier request to create OrderedHash as an alias of<br>
Hash? If that were to happen, I'd be happy if OrderedHash#keys returned an<br>
Array, and Hash#keys returned a Set. However if Hash remains explicitly<br>
ordered, Hash#keys should be likewise explicitly ordered (i.e. an Array).<br>
Unless we're also adding to spec that Set is insertion-ordered.</p>
<p>--<br>
Matthew Kerwin, B.Sc (CompSci) (Hons)</p> Ruby master - Feature #7796: Hash#keys should return a sethttps://bugs.ruby-lang.org/issues/7796?journal_id=359762013-02-07T20:07:01Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>For feature requests, please provide use cases and assessment on existing code, rather than "opinions".</p> Ruby master - Feature #7796: Hash#keys should return a sethttps://bugs.ruby-lang.org/issues/7796?journal_id=359952013-02-07T23:50:03Zalexeymuranov (Alexey Muranov)
<ul></ul><p>Matthew, in some sense it is indeed related to <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: Alias Hash 1.9 as OrderedHash (Rejected)" href="https://bugs.ruby-lang.org/issues/5123">#5123</a>, because both are about Set and Hash abstractions. However, it is independent, because as long as Hash is ordered, so is Set. If ever <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: Alias Hash 1.9 as OrderedHash (Rejected)" href="https://bugs.ruby-lang.org/issues/5123">#5123</a> is accepted and OrderedHash is separated from Hash, there will be also OrderedSet in addition to Set.</p>
<p>Martin, i will think about your request, but i do not really think in "use cases". I just think that "keys" of a Hash behave as a Set and not as an Array.</p> Ruby master - Feature #7796: Hash#keys should return a sethttps://bugs.ruby-lang.org/issues/7796?journal_id=360212013-02-08T07:47:22ZStudent (Nathan Zook)blogger@pierian-spring.net
<ul></ul><p>The first problem for me is that Hash is part of core while Set is part of the standard lib. One cannot have core depend on lib.</p>
<p>The second problem is that hash#keys has returned an array for the entire history of Ruby. It is far from clear to me that breaking that assumption is a good idea.</p>
<p>Now, Hash#key_set, defined when you do require 'set', has possibilities, if you have a use case.</p> Ruby master - Feature #7796: Hash#keys should return a sethttps://bugs.ruby-lang.org/issues/7796?journal_id=360252013-02-08T08:40:48Zalexeymuranov (Alexey Muranov)
<ul></ul><p>About the core/lib issue, there is an open request about adding Set to the core: <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Add syntax to import Set into core (Open)" href="https://bugs.ruby-lang.org/issues/5478">#5478</a>.</p> Ruby master - Feature #7796: Hash#keys should return a sethttps://bugs.ruby-lang.org/issues/7796?journal_id=890922020-12-10T08:49:17Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>3.0</i></del>)</li></ul>