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
		
- 
				
				I remember doing this when I was a supern00b.
 
 Is there something wrong with:
 
 if (returnsBool()) {
 //...
 }
 
 ?
 
 I suppose the only possible reason to use this:
 
 bool somebool = returnsBool();
 if (somebool) {
 //...
 }
 
 ... is if the result of retunsBool() will be used many times and the runtime of that method is not quite the fastest. So store the returned bool in a var to avoid multiple calls. Especially if that result isn't subject to change during runtime. Otherwise... WHY
- 
				
				 Voxera108839yI have seen it many times even from devs that should know better so I just write it of as temporary mental meltdown ;) Voxera108839yI have seen it many times even from devs that should know better so I just write it of as temporary mental meltdown ;)
- 
				
				I have to admit I just wrote the extract thing yesterday, I was helping a friend with his arduino project, he was really confused when I was calling a function within an if. So I had to sin
Related Rants







 It changed my life, really. 😁
It changed my life, really. 😁

 Found this in our codebase, apparently one of my co-workers had written this
Found this in our codebase, apparently one of my co-workers had written this
So I've been maintaining our company's web products for a few years now with a great senior dev, but why would it ever make sense to have a
bool somebool = returnsBool();
if (somebool == true)
...
WTF?!?! I still fine them in the code to this day.
undefined
code
c#
wtf