Ruby equivalent .items() method? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Ruby equivalent .items() method?

Is there a Ruby equivalent of the Python dictionary ".items()" method that returns a list of (key, value) pairs of a hash?

20th Mar 2017, 3:56 AM
David Ashton
David Ashton - avatar
2 Answers
+ 2
You can use the to_a method of hash
25th Mar 2017, 3:03 PM
Steven Wang
Steven Wang - avatar
+ 1
to_a method will do the trick
24th Apr 2017, 1:33 PM
Zafor Iqbal
Zafor Iqbal - avatar