i.e., is Ruby's Set equivalent to Java's LinkedHashSet?
In Ruby 1.9: yes. In Ruby 1.8: probably not.
Set uses a Hash internally; and since hashes are insertion-ordered in 1.9, you're good to go!
As mu is too short points out, this is an implementation detail and could change in the future (though unlikely). Thankfully, the current implementation of Set is pure ruby, and could be adapted into an OrderedSet in the future if you like
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With