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
-
@filthyranter it wouldnt, null checks always start with null for safety reasons. Same with "asd".equals(st)
-
RobertsR557yIf "value" = $value statement gives error but not other way around. That is why its safer.
-
@filthyranter because
a()==null will break BEFORE the evaluation while
null==a() will evaluate to whatever -
nicoco007757y@sharktits Will do. Then I'll probably have to go change a whole lot of stuff in what I've done in the past.
Shit. -
fdgram4867y@sharktits "a()==null will break BEFORE the evaluation while null==a() will evaluate to whatever"
What? -
@fdgram i think he means something like this:
String s = null;
if (s.equals("test")) // This will throw a NullPointerException because you can't invoke "equals" on null
if ("test".equals(s)) // works because "test" is a String on which equals can be invoked -
joykill3437yOr its the yoda statements I think it's called... As a safer way to code
Because if you so a single = instead of a double ==,
This: null = someParam errors out while someParam = null just assigns the value null to the parameter and continues the if -
fdgram4867y@youness Yoda conditions.
There's also a Yoda-style type of programming where you don't use exceptions.
"Do or do not; there is no try {"
Related Rants
One of my coworkers uses
if(null == something())
I know it's just coding style, but it fucking annoys me.
rant
coding style
coworkers
null