+ 1

why cant we use <> in switch statements like switch (age){ case < 16}, why we cant use <?

20th Dec 2016, 4:33 PM
Aqib Asmat
Aqib Asmat - avatar
4 Respuestas
+ 1
Because case/switch is specifically used for determined values such as 1 4 7 or 8 (for example), and using the < or > is selecting a wide range of numbers, and for that you have if(x > y) { }
20th Dec 2016, 4:36 PM
Syvered
Syvered - avatar
+ 1
Language syntax... Ruby supports such range in case... when... else
20th Dec 2016, 5:23 PM
Rishi Anand
Rishi Anand - avatar
+ 1
Actually, you can. Consider this code: Switch (True) case (age<16): This is within the language limits, even though it's not considered to be very readable programing...
22nd Dec 2016, 8:52 PM
itai rosenfeld
itai rosenfeld - avatar
0
ty guys
23rd Dec 2016, 12:43 PM
Aqib Asmat
Aqib Asmat - avatar