Undefined method 'to_h' on Ruby array
问题 As per Ruby Array documentation, there is a method to_h which can be used to convert arrays to hash as long as each element of the array is another array of two elements. Example below from the same documentation p [[:foo, :bar], [1, 2]].to_h However, when I run the above code, I get this error: irb(main):001:0> p [[:foo, :bar], [1, 2]].to_h NoMethodError: undefined method `to_h' for [[:foo, :bar], [1, 2]]:Array from (irb):1 from E:/RubyInstall/bin/irb:12:in `<main>' irb(main):002:0> My Ruby