DRAFT
MandatoryAssignment
Misconception:
An expression is not a valid statement on its own and must then be assigned to something to reach a valid statement.
Incorrect
An expression must be assigned to have a valid statement
Correct
An expression alone, without an assignment, is already a valid statement
CorrectionHere is what's right.
Here is what's right.
Among different types of statements, we have expression statements. This means that an expression on its own already constitutes a valid statement.
Consider this code that contains two valid statements. The first one assigns 3
to the constant a
, while the second one just computes the value 3
.