If and While

# If

In Wu, as mentioned, everything is an expression, even if-conditions. This means you can define your variables, call your functions etc. based on where the program flow is going.
Of course you can always decide to use vanilla if's:
1
if 2 + 2 == 2 {
2
print("it's actually two")
3
} elif 2 + 2 == 3 {
4
print("nevermind, it's three")
5
} else {
6
7
}
Copied!
Or not:
1
result := if 2 + 2 == 2 {
2
"it's two"
3
} elif 2 + 2 == 3 {
4
"it's three"
5
} else {
6
"something else"
7
}
8
9
print(result)
Copied!

# While

While-expressions work basically the same way as if-expressions, though they always return `()` - which is kind of useless, but for the sake of consistency and expression-oriented programming so whatever.
So, normal independent while loops:
1
a := 1
2
while a < 10 {
3
print(a)
4
a = a + 1
5
}
Copied!
You can also assign variables to while loops, if you for some reason wanted to do that:
1
b := 1
2
a := while b == 1 {
3
b = b - 1
4
}
5
6
# at this point `a` is nil :))
Copied!