book icon indicating copy to clipboard operation
book copied to clipboard

Ambiguity in the term expression used in the match control flow chapter

Open smithshelke opened this issue 3 years ago • 0 comments

  • [x] I have checked the latest main branch to see if this has already been fixed
  • [x] I have searched existing issues and pull requests for duplicates

URL to the section(s) of the book with this problem:

Description of the problem:

This seems very similar to an expression used with if, but there’s a big difference: with if, the expression needs to return a Boolean value, but here, it can return any type. The type of coin in this example is the Coin enum that we defined on the first line.

The above passage is from the The Match Control Flow Construct Chapter. Here it says that the if expression needs to return a Boolean value which is not true as there are examples in the previous control flow chapter which returns the value integer. All the chapters until this chapters have very frequently used the term expression that means anything that evaluates to a value. By that definition the if condition {} else {} is an expression as it evaluates to a value returned from the if else blocks. The ambiguity arises because of the term expression used interchangeably with condition, i feel. This might not be confusing for someone who is reading this book without actually having read the previous chapters that builds the understanding of the term expression and is used very frequently throughout.

Suggested fix: Use of a better word here instead of the term expression, like condition or subexpression

smithshelke avatar May 19 '22 18:05 smithshelke