You can easily use switch to check whether a number is in specified range.
We have seen the advantages of using switch instead of if/else.
|
|
You are sold by now, but there is this problem - how will you use switch if you need to check whether num < 10 and num > 5.
You may have missed this from our date validation logic, but switch can do the range checks well. You just have to change the conditions a bit.
|
|