Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
MAGNUMpt2028yIf var is null, it won't throw a null exception and would still make the comparison. This is preferred by many which avoids code like
var != null && var.equals("test") -
Well "test".equals(var) is promoted because if var is null it won't cause a null point exception, and it's cleaner looking than a null check then var.equals but besides that i agree i don't like the way it looks either
-
@R01101111bert @MAGNUMpt @jckimble I see, I didn't think of that.
Then again, I think a null-check is nicer than "test".equals(var). -
@Larsg310 null check only clutters the statement, and you have to read extra check before getting to the actual check when inspecting code
-
@osmarks while that might work in other languages, it might not work in all e.g. Java.
Related Rants
I'm getting annoyed by the smallest things, like when someone does "test".equals(var) instead of var.equals("test").
It not only reduces readability, it just doesn't look right to me. And I don't think there's a difference in performance between the 2.
undefined
performance
readability
equals
java