Ruby/Array/Array Subtraction

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Array Subtraction and Difference

# You can compare two arrays by subtracting one against the other. 
# This technique removes any elements from the main array that are in both arrays:
x = [1, 2, 3, 4, 5]
y = [1, 2, 3]
z = x - y
puts z.inspect