If statement
Syntax
if <condition> <body> [else <body>]
If-chain
if cond {
// ...
} else if cond2 {
// ...
} else {
// ...
}
In fact, the code above same to...
if cond {
// ...
} else {
if cond {
// ...
} else {
// ...
}
}
Last updated
Was this helpful?