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
-
C0D4681455yWorks in JS
Works in php
Probably works in a lot of langauges as EOL isn't bound by logical operators -
Yes, this will probably run in most languages. It's the same thing as
while(condition);
A very common way of clearing a buffer is to do
while(buffer.read());
When the buffer is empty, it will return null, and the loop will end.
This is allowed because it (like most other control structures) looks for a single block of code after it's declared. That's why you can omit brackets when you only need a single statement after an if.
The brackets act as a single statement: a scope statement. You increase the depth of the scope and put code in it.
A blank statement is still a statement. So just ending the line with a semicolon should be allowed by most control structures in most languages -
Konsole31215yThis is not threat. You are basically telling the compiler, if you don't execute that 'if', there is nothing else I can do.
That's more like pleading -
MrCush1225y@AlgoRythm I don’t know why I never understood why the input buffer would clear when throwing it in an if statement before. I always had the issue of clearing it until I read online that you could do that.
If(std::cin >> input)
Thanks for pointing out the obvious.....it was fucking scope all along lmao. Why didn’t I think of that? *smacks forehead* -
Mirinum1075yI'm pretty sure compiler will ignore this (at least at C++)
Nowadays compilers are pretty smart and they will ignore useless code, and try to optimize other code
Related Rants
can anyone confirm if this works?
joke/meme
rant
meme