ruby - Own class with spaceship operator does not work for LCS Diff -
i'm trying implement custom class including comparable mixin. later class used diff. class looks like class element include comparable attr_reader :name def initialize(name) @name = name end def <=>(other) @name <=> other.name end end now test values 2 added entries compared a. a = array.new b = array.new a.push element.new('y1') a.push element.new('y2') a.push element.new('y4') a.push element.new('x1') a.push element.new('x2') a.push element.new('x4') b.push element.new('y1') b.push element.new('y2') b.push element.new('y3') b.push element.new('y4') b.push element.new('x1') b.push element.new('x2') b.push element.new('x3') b.push element.new('x4') and run diff between both arrays puts diff::lcs.diff(a, b).inspect i expect 2 added objects finds 8 changes... ideas why? [[["-", 2, #<element:0x007fa9fb567898 ...