I am trying to find the intersection values between multiple arrays.
for example
code1 = [1,2,3]
code2 = [2,3,4]
code3 = [0,2,6]
So the
Ruby 2.7 introduced Array#intersection method to match the more succinct Array#&.
So, now, [1, 2, 3] & [2, 3, 4] & [0, 2, 6]
can be rewritten in a more verbose way, e.g.
[1, 2, 3].intersection([2, 3, 4]).intersection([0, 2, 6])
# => [2]
[1, 2, 3].intersection([2, 3, 4], [0, 2, 6])
# => [2]