Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Created June 14, 2013 13:49
Show Gist options
  • Save kylewelsby/5781941 to your computer and use it in GitHub Desktop.
Save kylewelsby/5781941 to your computer and use it in GitHub Desktop.
Find common items within two arrays.
a1 = ["html", "body", "ul", "li", "a"]
a2 = ["html", "body", "ul", "li", "p"]
a1.zip(a2).map{|n| n.first if n.first == n.last}.compact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment