i.e., is Ruby’s Set equivalent to Java’s LinkedHashSet?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Ruby 1.9: yes. In Ruby 1.8: probably not.
Setuses aHashinternally; 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
Setis pure ruby, and could be adapted into anOrderedSetin the future if you like