On 17.08.2007 21:00, Gordon Thiesfeld wrote: >> Why the difference doesn't work like [1, 2] - [2] ? >> -- > > Prova.new(2) and Prova.new(2) are two different objects. But with > Fixnums, there is only ever one 2. That's not the reason: you have to implement the right methods: irb(main):001:0> class Foo; def eql?(o) true end; def hash() 0 end end => nil irb(main):002:0> [Foo.new, Foo.new]-[Foo.new] => [] Matteo, it's easier when you use Struct. In that case your class becomes a one liner: Prova = Struct.new :n irb(main):003:0> Prova = Struct.new :n => Prova irb(main):004:0> p1 = [Prova.new(1), Prova.new(2)] => [#<struct Prova n=1>, #<struct Prova n=2>] irb(main):005:0> p2 = [Prova.new(2)] => [#<struct Prova n=2>] irb(main):006:0> p1 - p2 => [#<struct Prova n=1>] If you need more methods you can use a block: Prova = Struct.new :n do def your_method(x) x + n end end Kind regards robert