Module: Utopia::Extensions::ArraySplit
- Defined in:
- lib/utopia/extensions/array_split.rb
Overview
Adds splitting helpers to arrays.
Instance Method Summary collapse
-
#split_at(*arguments, &block) ⇒ Object
Split the array around the first element matching the arguments or block.
Instance Method Details
#split_at(*arguments, &block) ⇒ Object
Split the array around the first element matching the arguments or block.
15 16 17 18 19 20 21 |
# File 'lib/utopia/extensions/array_split.rb', line 15 def split_at(*arguments, &block) if middle = index(*arguments, &block) [self[0...middle], self[middle], self[middle+1..-1]] else [[], nil, []] end end |