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.
1 Answer