gilbert189 @gilbert189

is there a programming language that doesn’t support else if at all

not even as the sneaky “second if is inside else

Mar 8, 2024, 12:16 AM
3
View all

comments

Highlighted comment

I'd say that, as long as a programming language supports IF, AND and NOT, then there should be a workaround for ELIF in there somewhere. For example,

IF (BOOL-A) {
  FUNCTION(A)
} ELIF (BOOL-B) {
  FUNCTION(B)
} ELSE {
  FUNCTION(C)
}

could be worked around like this:

IF (BOOL-A) {
  FUNCTION(A)
}
IF (!BOOL-A && BOOL-B) {
  FUNCTION(B)
]
IF (!BOOL-A && !BOOL-B) {
  FUNCTION(C)
}