0

How to use greater than,less than operators in switch function ? How to use greater than,less than operators in switch function

12th Aug 2018, 10:43 PM
Ricardo Portillo
Ricardo Portillo - avatar
2 ответов
+ 1
unfortunately its nearly impossible, but u can use IF statement or unary👌 [EDIT] if not, you can use multiple case statement without breaking them for example x < 3 use this 👇 switch(x){ case 0: case 1: case 2: //code here break; } but its to difficult and a waste of time, because in the example above 👆 the statement is true for every positive integer, remember -1, -2, -3, ...-n; also include in (x < 3). so, using switch to test logical operators isnt the right choice😀
12th Aug 2018, 10:53 PM
Nura Programmer
Nura Programmer - avatar
+ 1
You can also force it, like this 👇 x < 3 use this code switch(x < 3){ case true: //your code here break; } you can see in any way using IF is the most efficient way hope this help😀
12th Aug 2018, 11:25 PM
Nura Programmer
Nura Programmer - avatar