jeudi 25 avril 2019

Why are if expressions and if statements in ada

Taken from adacore.com:

Ada's if expressions are similar to if statements. However, there are a few differences that stem from the fact that it is an expression:

All branches' expressions must be of the same type

It must be surrounded by parentheses if the surrounding expression does not already contain them

An else branch is mandatory unless the expression following then has a Boolean value. In that case an else branch is optional and, if not present, defaults to else True.

I do not understand the need to have two different ways of constructing code with the if keyword. What is the reasoning behind this?

Aucun commentaire:

Enregistrer un commentaire