module FatCore::Array

Public Instance Methods

difference(other) click to toggle source

Return an Array that is the difference between this Array and other, but without removing duplicates as the Array#- method does. All items of this Array are included in the result unless they also appear in the other Array.

# File lib/fat_core/array.rb, line 27
def difference(other)
  result = []
  each do |itm|
    result << itm unless other.include?(itm)
  end
  result
end
intersect(other) click to toggle source

Return a new Array that is the intersection of this Array with other, but without removing duplicates as the Array#& method does. All items of this Array are included in the result but only if they also appear in the other Array.

# File lib/fat_core/array.rb, line 15
def intersect(other)
  result = []
  each do |itm|
    result << itm if other.include?(itm)
  end
  result
end
last_i() click to toggle source

Return the index of the last element of this Array. This is just a convenience for an oft-needed Array attribute.

# File lib/fat_core/array.rb, line 7
def last_i
  size - 1
end