My orginal hash is like as
==> hash = {"sku_id"=>[4],
"brand_active"=>["true"],
"salesman_active"=>["true"]}
How to remove the array within hash. that means to convert the hash like
==> {"sku_id"=>4, "brand_active"=>"true",
"salesman_active"=>"true"
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Come on, why even ask this!? Check the doc for all essentials -- Array, Hash,
String.
hash.each { |k,v| hash[k] = v[0] }
- A
On 02/09/2010, at 1:49 PM, Manivannan Jeganathan wrote:
> My orginal hash is like as
>
> ==> hash = {"sku_id"=>[4],
"brand_active"=>["true"],
> "salesman_active"=>["true"]}
>
> How to remove the array within hash. that means to convert the hash like
>
> ==> {"sku_id"=>4,
"brand_active"=>"true",
"salesman_active"=>"true"
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
On Sep 2, 6:49 am, Manivannan Jeganathan <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> ==> hash = {"sku_id"=>[4], "brand_active"=>["true"], > "salesman_active"=>["true"]} > > How to remove the array within hash.In addition to Aleksey''s response re how to UNdo the arraying, would it be possible simply to NOT put the data in as arrays in the first place? -Dave -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.