Ruby Combine Hash Key As Hash + Key and return as array -


suppose have hash

hash = {"123"=>"abc", "124"=>"def"}

i'm expecting output

[["123 - abc", "123"], ["124 - def", "124"]] pass select tag display "123 - abc" , submit id when selected

i came solution

hash.map{|key,value| ["#{key} - #{value}",key]}

but there better way other this?


Comments

Popular posts from this blog

ruby - How do I merge two hashes into a hash of arrays? -

c++ - Do gcc's __float128 floating point numbers take the current rounding mode into account? -