Module: ArrayUtil

Included in:
MarkdownExec::MarkParse
Defined in:
lib/array_util.rb

Class Method Summary collapse

Class Method Details

.partition_by_predicate(arr) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/array_util.rb', line 7

def self.partition_by_predicate(arr)
  true_list = []
  false_list = []

  arr.each do |element|
    if yield(element)
      true_list << element
    else
      false_list << element
    end
  end

  [true_list, false_list]
end