Methods
to_h
Public Instance methods
Convert an Enumerable::Enumerator object directly into a hash.
e = [1,2,3,4,5].to_enum e.to_h #=> {5=>nil, 1=>2, 3=>4} e2 = [1,2,1,3,1,5].to_enum e2.to_h #=> {1=>5} e3 = [[1,:a],[2,:b],[3,:c]].to_enum e3.to_h #=> { 1=>:a, 2=>:b, 3=>:c }
CREDIT: Sandor Szücs
[ + ]
# File lib/core/facets/to_hash.rb, line 304 def to_h(mode=nil) to_a.to_h(mode) end