Re: [Codenarc-developer] UnnecessaryEqualityWithNull rule
Brought to you by:
chrismair
From: Hamlet D. <ham...@ca...> - 2011-06-06 05:31:02
|
I never thought of this scenario. However, isn't x.equals(null) and x == null the same thing? I'd prefer the latter. ----- Original Message ----- > > > > > The documentation for UnnecessaryEqualityWithNull says > > The expression object.equals(null) is always false and is > unnecessary. > > The object.equals(null) comparison will always return false, since > the object is not null. (If the object is null, the program will > throw a NullPointerException). This is the basic contract of the > equals() method. > > > > But this prints true in the GroovyConsole, rather than throwing a > NPE: > > > > def x = null > > println x.equals(null) > > > > Any thoughts on what to do with this rule? > ------------------------------------------------------------------------------ > Simplify data backup and recovery for your virtual environment with > vRanger. > Installation's a snap, and flexible recovery options mean your data > is safe, > secure and there when you need it. Discover what all the cheering's > about. > Get your free trial download today. > http://p.sf.net/sfu/quest-dev2dev2 > _______________________________________________ > Codenarc-developer mailing list > Cod...@li... > https://lists.sourceforge.net/lists/listinfo/codenarc-developer > |