Method: Array#push_ordered
- Defined in:
- lib/y_support/core_ext/array/misc.rb
#push_ordered(element) ⇒ Object
With array construction syntax [:foo, bar: 42] now possible in Ruby, arrays become closer to argument collections, and supporting methods might come handy. This method pushes an element on top of the “ordered arguments” part of the array.
88 89 90 91 |
# File 'lib/y_support/core_ext/array/misc.rb', line 88 def push_ordered element return push element unless last.is_a? Hash push pop.tap { push element } end |