Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/core_ext/ruby/array/flatten_once.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#flatten_once ⇒ Object
2 3 4 |
# File 'lib/core_ext/ruby/array/flatten_once.rb', line 2 def flatten_once inject([]) { |result, elem| elem.is_a?(Array) ? result + elem : result << elem } end |
#flatten_once! ⇒ Object
6 7 8 |
# File 'lib/core_ext/ruby/array/flatten_once.rb', line 6 def flatten_once! replace(flatten_once) end |