Unclear listing 5.13


Why can’t I just use

i​f​ ​c​a​s​e​ ​21.​.​.​3​5​ ​=​ ​a​g​e​ ​{​
​ ​ ​ ​p​r​i​n​t​(​"​C​o​o​l​ ​d​e​m​o​g​r​a​p​h​i​c​ and of drinking age"​)​

whats the meaning of using

if​ ​c​a​s​e​ ​1​8​.​.​.​3​5​ ​=​ ​a​g​e​ ​w​h​e​r​e​ ​a​g​e​ ​>​=​ ​2​1​ ​{​
​ ​ ​p​r​i​n​t​(​"​I​n​ ​c​o​o​l​ ​d​e​m​o​g​r​a​p​h​i​c​ ​a​n​d​ ​o​f​ ​d​r​i​n​k​i​n​g​ ​a​g​e​"​)​


Hi Hovac,

Your code doesn’t match with the code given the book.
The values in first if case are 18…35 (You are checking 21…35) In my view thats the reason you have not understood the concept.
I will explain both cases.
The first “if case” will be executed only when the value of “age” is between 18 & 35
The second if case will be executed when the value of “age” is between 18 & 35 and “age” is above or equal to 21


That’s what I was asking. Whats the reason of writing 18…35 where >= 21, if I could write 21…35 instead, I did’t make mistake copying, it was the proposed version.


Real late but I’m just getting started. You can do just as you suggest, but I guess the example is for an establishment that the minimum age is 18. If it were only 21 and up then the where clause is unnecessary.