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 you use a text editor (not notepad) / IDE, a font color change may tell which one is the correct syntax.
-
you could always do
If(condition) {
} else {
if(condition) {
}
}
// ¯\_(ツ)_/¯ -
condition && (f1() || true) || (f2() || true)
I think that works in most languages... But probably easier to just remember which if/else variant to use. -
Noob64608yTotally feel you. We all need to be united under one syntactic language and one benevolent, supreme leader - Kim Jong Un!
-
I want to know what ass hat in the Visual Basic team said "you know, we need to add 'then' to the end of each if statement"
-
@Ashkin yes there is, ex in Java if you type "else if" it will compare two conditions if an if or else if statement's condition is false, but of you type elseif it won't compile
-
Root797678y@calmyourtities
Not all languages have an `elseif` -- and with good reason: it's pointless.
if (condition) {
...
} else if (condition) {
...
}
So if the first condition is false, it compares the second condition. How is this different than `elseif`? Spoiler: it isn't! -
@Ashkin many people argue that using any form of "else" is an antipattern, because the if should contain the least likely path with an early return to the caller, and methods should be short and modular.
Related Rants
Else if, elif, elseif, if else garrgghj. I can never remember what it is in whatever language I happen to use...
undefined
if else