Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/ruby_extensions.rb
Overview
Various monkeypatching
Instance Method Summary collapse
-
#to_h ⇒ Object
Turns an array of the form [[key, value], …] into a hash of the form {key => value } [[:a, 1], [:b, 2]].to_h #=> => 1, :b => 2.
Instance Method Details
#to_h ⇒ Object
Turns an array of the form [[key, value], …] into a hash of the form {key => value }
[[:a, 1], [:b, 2]].to_h #=> {a => 1, :b => 2}
6 7 8 |
# File 'lib/ruby_extensions.rb', line 6 def to_h inject({}) { |m, e| m[e[0]] = e[1]; m } end |