What is an efficient way to describe three different cases for x<y
, x>y
and x=y
? Here x
and y
are two numbers. I thought the following:
if (x<y) {
...
}
if (x>y) {
...
}
if (x=y) {
...
}
Maybe I could use ifelse
statement?
What is an efficient way to describe three different cases for x<y
, x>y
and x=y
? Here x
and y
are two numbers. I thought the following:
if (x<y) {
...
}
if (x>y) {
...
}
if (x=y) {
...
}
Maybe I could use ifelse
statement?
The else-if construction should be on the same line as the last brace of the preceding block.
The ifelse function is probably not what you're looking for if you're looking to execute multiple statements.
if (x<y) {
...
} else if (x>y) {
...
} else if (x=y) {
...
}