Ruby/Array/Array Subtraction

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

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

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