From a3bccdebcf67b49271a319bc1101607992fc366d Mon Sep 17 00:00:00 2001 From: ghm Date: Fri, 14 Sep 2018 03:03:47 -0700 Subject: [PATCH] Remove text about enums from ReferenceEquality check, as it doesn't check 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 --- docs/bugpattern/ReferenceEquality.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/bugpattern/ReferenceEquality.md b/docs/bugpattern/ReferenceEquality.md index 73c055dae79..a83bea2d626 100644 --- a/docs/bugpattern/ReferenceEquality.md +++ b/docs/bugpattern/ReferenceEquality.md @@ -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