2021-06-08 14:23:48 +02:00
|
|
|
An ``++equals++`` method that unconditionally returns the same answer is an error likely to cause many bugs.
|
|
|
|
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,java]
|
2021-06-08 14:23:48 +02:00
|
|
|
----
|
|
|
|
public class Fruit extends Food {
|
|
|
|
private Season ripe;
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
return ripe.equals(this); // Noncompliant
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-08 14:23:48 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|