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
-
If the language itself permits assignments in an if-clause, i'ts rather a fact of bad language or compiler / interpreter design. If it is an intended feature , the compiler atleast should give you a warning, or introduce a new syntax to make it more verbose.
-
Voxera113886yTry to use fira code font or similar. It displays double and triple equal very differently from single to make it easier to spot such mistakes.
-
Voxera113886y@TheCPPanda To bad they did not go with pascals := for assignment, it would have made it harder to do wrong.
-
C0D4669026yAh, I've been there before 😂
Although a coworker in used to work with use to do callback hell in if() statements
If( ($x = json_decode(callSomeAPi($args), true) ) !== false){
//welcome to hell
SendXSomewhereElse($x);
}
I get so lost looking at these, and when there is multiple conditions and an assignment 😱🔫
Fuck I hate php some days, but fuck I love php. -
@TheCPPanda if we're speaking about modern practices, then you are probably right. There are some really clever uses of it in C though.
-
potata14776y@C0D4 To be fair, I've had such cases:
while($variable = DB_QUERY !== null) {}
and it's pretty great after all but... At other times you can fuck up so much :D
Related Rants
I've lost hope in my precision at this point:
We've updated our website to have X feature. The X feature was implemented, tested and even had unit tests... The worst part when I've lost hope? Both unit and the actual code had the same mistake in them. What was the mistake? Well...
if($variable = 'something') {}
Yeah... Read it carefully... We've always had the same case and only noticed it after 3 months when it was attempted to extend.
Funny enough, few users were harmed but no actual reports of an issue came to us.
Since then, I'm always triple checking that I have the correct amount of `=` to avoid further fuck-ups
rant
wk152