Mega Code Archive

 
Categories / Ruby / Array
 

Add new operator for Array

class Array   def ^(other)     (self | other) - (self & other)   end end x = [1, 2, 3, 4, 5] y = [3, 4, 5, 6, 7] z = x ^ y            # [1, 2, 6, 7]