Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby intersection of two arrays

x = [1, 1, 2, 4]
y = [1, 2, 2, 2]

# intersection
x & y            # => [1, 2]

# union
x | y            # => [1, 2, 4]

# difference
x - y            # => [4]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #intersection #arrays
ADD COMMENT
Topic
Name
5+4 =