Skip to content

Commit

Permalink
Fix Diff documentation (#237)
Browse files Browse the repository at this point in the history
The description inaccurately describes the operation of Diff,
which is y - x, where a '+' prefix denotes elements added from y
and a '-' prefix denotes elements removed from x.

For example:
	// Consider this call to Diff and its result.
	                  x  y
	cmp.Diff({b:2, c:3}, {a:1, b:2}) => {+a:1, b:2, -c:3}

	// Consider the same in mathematical notation.
	         y - x
	{a:1, b:2} - {b:2, c:3} = {+a:1, b:2, -c:3}
  • Loading branch information
dsnet authored Nov 12, 2020
1 parent d3c8501 commit 0a3ecd3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmp/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ func Equal(x, y interface{}, opts ...Option) bool {
// same input values and options.
//
// The output is displayed as a literal in pseudo-Go syntax.
// At the start of each line, a "-" prefix indicates an element removed from y,
// a "+" prefix to indicates an element added to y, and the lack of a prefix
// At the start of each line, a "-" prefix indicates an element removed from x,
// a "+" prefix to indicates an element added from y, and the lack of a prefix
// indicates an element common to both x and y. If possible, the output
// uses fmt.Stringer.String or error.Error methods to produce more humanly
// readable outputs. In such cases, the string is prefixed with either an
Expand Down

0 comments on commit 0a3ecd3

Please # to comment.