9

Is there a quick way to flatten a hash into an array with the keys removed?

h={:at => [10, 20], :width => 100, :height => 200}

and result to:

[[10, 20], 100, 200]
1
  • 1
    sorry. accept mean click on the check-mark icon? Thanks! Commented Oct 12, 2012 at 19:31

2 Answers 2

14

There is a built-in hash method: h.values

Sign up to request clarification or add additional context in comments.

Comments

5

This is pretty easy:

h.values

If you want it in a particular order you'll need to do some more work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.