integer :: i
i = if (.true.) then 10 else 20 endif
i
10
i = if (.false.) then 10 else 20 endif
i
20
if (.false.) then 10 else 20 endif + 50
70
3 * if (.false.) then 10 else 20 endif + 50
110
The then
and else
expressions must have the same type, otherwise you get an error:
i = if (.true.) then 10 else "x" endif
input:1:5 semantic error: The type of then and else expressions must match in conditional expression i = if (.true.) then 10 else "x" endif ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~