I have such array in ruby (document language [even index] and number of words [odd index])
words = ["en",200,"ru","120","es",140,"ru",240]
Final result should look like:
{"en"=>200,"ru=>360","es"=>140}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ah, you need to sum duplicate keys. So, the
Hash::[]method won’t work here. No problem, useeach_slice+each_with_objectthen: