Get difference of arrays in Ruby [duplicate]

Possible Duplicate:
diff a ruby string or array

I have an old array: [1, 2, 3, 4, 5], and new: [1, 2, 4, 6]

How to get difference with Ruby: that 5, 3 was removed and 6 was added?


Solution 1:

irb(main):001:0> a = [1, 2, 3, 4, 5]
=> [1, 2, 3, 4, 5]
irb(main):002:0> b = [1, 2, 4, 6]
=> [1, 2, 4, 6]
irb(main):003:0> a - b
=> [3, 5]
irb(main):005:0> b - a
=> [6]
irb(main):006:0>