From: Emeka Patrick Date: 2012-06-25T15:35:31+09:00 Subject: Re: Stripping symbol character from hash turned to array Thanks for the help and the explanation behind everything, I think I have a handle on it now! Thanks again, Emeka Michal Karas wrote in post #1065824: > On Sun, 24 Jun 2012 10:38:28 +0900 > Emeka Patrick wrote: > >> If I want to keep it as a nested Array how can I go about stripping the >> ":" from what used to be the key. Please help and if possible, explain. > > As other responders already said, ":" is only a notation for Symbol. It > has nothing to do with being a key in a Hash. In fact you can use > Strings as keys for your Hash and then Hash#to_a will produce directly > the result you want: > >> { "fred" => 23, "joan" => 18, "pete" => 54 }.to_a > => [["fred", 23], ["joan", 18], ["pete", 54]] > > Although if you want to use Symbols as Hash keys and then having > Strings in resulting nested Array, you can use Hash#map method to do > the transformation: > >> { :fred => 23, :joan => 18, :pete => 54 }.map { |key,value| [key.to_s, value] } > => [["fred", 23], ["joan", 18], ["pete", 54]] -- Posted via http://www.ruby-forum.com/.