Skip to content

Commit

Permalink
Remove text about enums from ReferenceEquality check, as it doesn't c…
Browse files Browse the repository at this point in the history
…heck them.

I considered rephrasing it to say that using #equals is preferred but not enforced by this check, but mentioning them at all seems confusing.

Fixes #783

RELNOTES: Tweak documentation for ReferenceEquality

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212956380
  • Loading branch information
graememorgan authored and cushon committed Sep 17, 2018
1 parent b516c89 commit a3bccde
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions docs/bugpattern/ReferenceEquality.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ Well, no, because some tricky client can always generate a new instance with
`new Boolean(true)`. Comparing with `equals` always works; comparing with `==`
doesn't.

### But `enum` values are always unique, so can't I compare _them_ with `==`?

Yes, _but_ that might confuse the reader, who must understand that your type has
special properties because it's an `enum`. Using `equals` everywhere can work
the same everywhere; special-casing for enums isn't worth it.

### How about a reference equality comparison before a more expensive content equality comparison?

The check allows implementations of `Object#equals()` to perform reference
Expand Down

0 comments on commit a3bccde

Please sign in to comment.