halostatue / diff-lcs

Generate difference sets between Ruby sequences.
http://halostatue.github.com/diff-lcs
Other
289 stars 56 forks source link

Add documentation how to override object equality #70

Open coezbek opened 3 years ago

coezbek commented 3 years ago

It is unclear to me if (at all) and how to define what constitutes equality for diff-lcs. I tried overriding == operator but this did not work.

Looking into the code it seems Hash equality needs to be implemented (i.e. eql? and hash).

https://github.com/halostatue/diff-lcs/blob/e4b02743f4f2d40cd43b0ec9071d6a5ba9787336/lib/diff/lcs/internals.rb#L294

Would it make sense to document this?

halostatue commented 3 years ago

It would be. I’d suggest that it might be worth adding some tests to verify this.