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