+ 1

Can we make code so switch can check two values in cases? Example in code. They are higlighted in comments (Sorry for my eng)

https://code.sololearn.com/c89L04tWQ2Lm/?ref=app

15th Jul 2019, 6:02 PM
Lily
Lily - avatar
6 Answers
+ 12
Lily... You will want to move the switch statement into another method and call that method for each value separately. See my code for how this would look... https://code.sololearn.com/c1KGhQ9Tf0mk/?ref=app
17th Jul 2019, 6:40 AM
David Carroll
David Carroll - avatar
+ 2
In your example, which 2 values do you want it to check?
15th Jul 2019, 6:14 PM
Sonic
Sonic - avatar
+ 2
Lily , Ace IMHO that's better achieved via if, else if, else without using switch.
15th Jul 2019, 10:58 PM
Sonic
Sonic - avatar
+ 1
I meant execute 2 cases but with different messages and values
15th Jul 2019, 6:19 PM
Lily
Lily - avatar