0

Let's say I've got hash like this:

{"290"=>{"id"=>"290", "name"=>"Test Number", "order"=>"2"}}

I want to to have:

{"id"=>"290", "name"=>"Test Number", "order"=>"2"}
user2931706
  • 195
  • 1
  • 11
  • possible duplicate of [Ruby Hash to array of values](http://stackoverflow.com/questions/9560335/ruby-hash-to-array-of-values) – Matt Burrow Jan 23 '15 at 11:51
  • 1
    If that's the form of your hash (say `h`), but values may vary, then `h.values.first` or `h.to_a.first.last` will do it. – Cary Swoveland Jan 23 '15 at 15:34

2 Answers2

1

Let's say h = {"290"=>{"id"=>"290", "name"=>"Test Number", "order"=>"2"}}. Now you can do h = h["290"] and you will have what you want.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176
0

Please check below image: It's show different approaches to get the same result :D enter image description here

Ajay
  • 4,199
  • 4
  • 27
  • 47