Issue #9239 has been updated by marcandre (Marc-Andre Lafortune).

Category set to core
Assignee changed from matz (Yukihiro Matsumoto) to marcandre (Marc-Andre Lafortune)
Target version set to current: 2.1.0

I got the green light from Matz, thanks :-)

Naruse-san: could you please confirm that there is no problem on your end for me to commit the following patch: https://github.com/marcandre/ruby/compare/to_h_raise

Thanks
----------------------------------------
Feature #9239: Array#to_h ignores flat arrays
https://bugs.ruby-lang.org/issues/9239#change-43726

Author: sawa (Tsuyoshi Sawada)
Status: Open
Priority: Normal
Assignee: marcandre (Marc-Andre Lafortune)
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/