From: "naruse (Yui NARUSE)" <naruse@...> Date: 2013-12-21T01:02:40+09:00 Subject: [ruby-core:59232] [ruby-trunk - Feature #9239][Rejected] Array#to_h ignores flat arrays Issue #9239 has been updated by naruse (Yui NARUSE). Status changed from Open to Rejected As Array#to_h says and test_to_h describes, Array#to_h is different from Hash[]. The behavior is expected one. Returns the result of interpreting <i>ary</i> as an array of <tt>[key, value]</tt> pairs. Elements other than pairs of values are ignored. ---------------------------------------- Feature #9239: Array#to_h ignores flat arrays https://bugs.ruby-lang.org/issues/9239#change-43784 Author: sawa (Tsuyoshi Sawada) Status: Rejected Priority: Urgent Assignee: naruse (Yui NARUSE) Category: core Target version: current: 2.1.0 =begin My understanding was that the newly introduced `Array#to_h` was to be equivalent to `Hash.[]`. But when I give a flat array, it returns an empty hash: [:a, :b].to_h # => {} [:a].to_h # => {} I expected `{:a => :b}` for the first example, and `ArgumentError: odd number of arguments for Hash` for the second example, as is with `Hash[]`. Was it intended to be different? If so, why is that the case? Even if it is to be different, it should at least raise an error when a flat array is given. =end -- http://bugs.ruby-lang.org/