ruby merge two arrays code example
Example 1: ruby merge array unique
a = [0,1,2,3,4]
b = [2,3,4,5,6,7,8,9,0]
c = a | b
=> [0,1,2,3,4,5,6,7,8,9]
Example 2: merge two lists together ruby
# Merging
c = a + b
=> [1, 2, 3, 4, 5, 2, 4, 6]
# Removing the value of other array
# (a & b) is getting the common element from these two arrays
c - (a & b)
=> [1, 3, 5, 6]