Closed
Description
Original issue created by kevinb@google.com on 2012-11-02 at 01:57 PM
There is no good reason to test a primitive value or reference for inequality with itself. It is likely to mask a bug, or at least be pointlessly confusing.
The fix for 'foo != foo' is
- if foo is of type float, replace with 'Float.isNaN(foo)'
- if foo is of type double, replace with 'Double.isNaN(foo)'
- otherwise, the transliteration is obviously to replace with 'false', which of course might not be want the user intended...
Here's an example of something this would have caught in the JDK:
http://bugs.sun.com/view_bug.do;jsessionid=a3391b8310ec77f33a52e1afb90d?bug_id=6958423
Activity
cushon commentedon Oct 31, 2014
Original comment posted by eaftan@google.com on 2013-02-11 at 09:34 PM
(No comment entered for this change.)
Status: Accepted