Skip to content

cotrIfElse

Creates an if…else statement

Aliases:

  • cotrIfElse
  • ifElseStatement

cpp

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

csharp

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

dart

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

go

if condition {
// Your code here
} else if condition {
// Your code here
} else {
// Your code here
}

haskell

if condition
then expression1
else expression2

java

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

javascript

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

javascriptreact

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

kotlin

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

perl

if (condition) {
# Your code here
} else {
# Your code here
}

php

if (condition) {
// Your code here
} else {
// Your code here
}

powershell

Terminal window
if (condition) {
# Your code here
} else {
# Your code here
}

python

if condition:
# Your code here
else:
# Your code here

r

if (condition) {
# Your code here
} else {
# Your code here
}

ruby

if condition
# Your code here
elsif condition
# Your code here
else
# Your code here
end

rust

if condition {
// Your code here
} else if condition {
// Your code here
} else {
// Your code here
}

scala

if (condition) {
// Your code here
} else {
// Your code here
}

shellscript

Terminal window
if [ condition ]; then
// Your code here
else
// Your code here
fi

swift

if condition {
// Your code here
} else if condition {
// Your code here
} else {
// Your code here
}

typescript

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}

typescriptreact

if (condition) {
// Your code here
} else if (condition) {
// Your code here
} else {
// Your code here
}