Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/ext/array.rb
Instance Method Summary collapse
Instance Method Details
#invert(&block) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/ext/array.rb', line 2 def invert(&block) h = {} self.each_with_index do |x, i| h[x] = block ? yield(x, i) : i end h end |