Project

General

Profile

Actions

Bug #14069

closed

Document order of elements in Set

Bug #14069: Document order of elements in Set

Added by abotalov (Andrei Botalov) almost 8 years ago. Updated about 6 years ago.

Status:
Rejected
Target version:
-
ruby -v:
2.4
[ruby-core:83614]

Description

Hash enumerates values in the insertion order.

Set is built on Hash so it does the same.
However, this is currently believed to be a not documented implementation detail. See:
https://stackoverflow.com/a/14468621/841064
https://stackoverflow.com/questions/10361250/does-set-in-ruby-always-preserve-insertion-order#comment13351258_10361275
https://spin.atomicobject.com/2012/09/04/when-is-a-set-better-than-an-array-in-ruby/

I think it would be better to explicitly document that Set class enumerates keys in the insertion order.

Updated by jwmittag (Jörg W Mittag) almost 8 years ago Actions #1 [ruby-core:84680]

Is that actually guaranteed by the specification? Can you point to any specification or documentation or official statement by the core team that supports your assertion that sets are insertion-ordered?

Updated by jeremyevans0 (Jeremy Evans) over 6 years ago Actions #2 [ruby-core:93334]

  • Status changed from Open to Assigned
  • Assignee set to knu (Akinori MUSHA)

I believe the fact that sets are currently insertion ordered due to the use of hash is an implementation detail, and we shouldn't document it.

Updated by jeremyevans0 (Jeremy Evans) about 6 years ago Actions #3

  • Status changed from Assigned to Rejected
Actions

Also available in: PDF Atom