diff --git a/History.md b/History.md index a49666f..3690990 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,8 @@ detection. [#44][] - Fixed a theoretical issue reported by Jun Aruga in Diff::LCS::Hunk to raise a more useful exception. [#43][] +- Added documentation that should address custom object issues as reported in + [#35][]. - Fixed more diff errors, in part reported in [#65][]. ## 1.4.3 / 2020-06-29 @@ -271,6 +273,7 @@ [#29]: https://github.com/halostatue/diff-lcs/pull/29 [#33]: https://github.com/halostatue/diff-lcs/issues/33 [#34]: https://github.com/halostatue/diff-lcs/pull/34 +[#35]: https://github.com/halostatue/diff-lcs/issues/35 [#36]: https://github.com/halostatue/diff-lcs/pull/36 [#38]: https://github.com/halostatue/diff-lcs/issues/38 [#43]: https://github.com/halostatue/diff-lcs/issues/43 diff --git a/lib/diff/lcs.rb b/lib/diff/lcs.rb index 6df8197..63888a1 100644 --- a/lib/diff/lcs.rb +++ b/lib/diff/lcs.rb @@ -60,6 +60,13 @@ module Diff::LCS # rubocop:disable Style/Documentation # +self+ and +other+. See Diff::LCS#lcs. # # lcs = seq1.lcs(seq2) + # + # A note when using objects: Diff::LCS only works properly when each object + # can be used as a key in a Hash, which typically means that the objects must + # implement Object#eql? in a way that two identical values compare + # identically for key purposes. That is: + # + # O.new('a').eql?(O.new('a')) == true def lcs(other, &block) #:yields self[i] if there are matched subsequences: Diff::LCS.lcs(self, other, &block) end