Module: DTK::Client::CommonUtil

Defined in:
lib/util/common_util.rb

Class Method Summary collapse

Class Method Details

.substract_array_once(array1, array2, substract_from_back = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/util/common_util.rb', line 22

def substract_array_once(array1, array2, substract_from_back = false)
  # we substract from reverse if flag set
  array1 = array1.reverse if substract_from_back

  array2.each do |element|
    if index = array1.index(element)
      array1.delete_at(index)
    end
  end

  substract_from_back ? array1.reverse : array1
end