Skip to content

Instantly share code, notes, and snippets.

@adamcarr
Created October 30, 2011 04:00
Show Gist options
  • Save adamcarr/1325457 to your computer and use it in GitHub Desktop.
Save adamcarr/1325457 to your computer and use it in GitHub Desktop.
ruby intersection of arrays
def intersect_arrays(arrays)
result = []
init = false
massaged_array = arrays.compact.uniq || []
massaged_array.each do |a|
unless init
result = a
init = true
else
result = result & a
end
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment