If Then Else in V

Posted by yhuang
Public (Editable by Users)
V
None
Edit
a := 10
b := 20
if a < b {
	println('$a < $b')
} else if a > b {
	println('$a > $b')
} else {
	println('$a == $b')
}

// if can be used as an expression:
num := 777
s := if num % 2 == 0 {
	'even'
}
else {
	'odd'
}
println(s) // "odd"