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
Post a Comment