Convert comma-separated string into hash in ruby
ruby
Solution
s = 'keyA,valueA,keyB,valueB'
Hash[*s.split(',')]
#=> { 'keyA' => 'valueA', 'keyB' => 'valueB' }
Problem
In Ruby, I need to convert a string like this: ``` "keyA,valueA,keyB,valueB" ``` into a hash like this: ``` {"keyA"=>"valueA", "keyB"=>"valueB"} ``` I'm pretty sure this will involve the `each_slice` method and possibly the enumerable `inject()`, as described in "ruby string to hash conversion". but I have no idea how to bring these components together.