Making Decisions
Programs get interesting when they can choose what to do based on what's happening. In Clean Language, you do that with if — and it reads almost exactly like plain English.
start:
integer temperature = 35
if temperature > 30
print("It's hot outside!")
else if temperature > 20
print("Nice weather today.")
else
print("Grab a jacket.")It's hot outside!The program checks each condition in order and runs the first one that's true. If none match, else is the catch-all at the bottom.
You can also check multiple things at once using and and or:
start:
integer age = 20
boolean hasTicket = true
if age >= 18 and hasTicket
print("Welcome in!")
else
print("Sorry, you can't enter.")Welcome in!No parentheses around the condition, no curly braces around the body. Just the condition, then indented code underneath. Clean keeps it as uncluttered as possible.
Quick recap
- if condition runs a block of code only when the condition is true
- else if condition adds more branches to check
- else is the fallback — runs when nothing else matched
- Use and to require both conditions, or for either one
- not flips a condition: if not active
- No parentheses around conditions, no braces — just indentation