There was an error while loading. Please reload this page.
The ternary operator can be used to evaluate different values based on a condition.
condition ? value1 : value2
bool
Only one of the two possible values will be evaluated. If the condition is true, the first will be, otherwise the second will be. Never will both be.
import basics func main { name String = scan("Enter your name: ") print(name == "Isaac" ? "Welcome!" : "Hi there " + name + "!") }
Table of Contents