Can you use strings in switch statements? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can you use strings in switch statements?

15th Mar 2018, 9:10 PM
TheAtom
TheAtom - avatar
4 Answers
+ 2
Could I use enumeration
15th Mar 2018, 9:27 PM
TheAtom
TheAtom - avatar
+ 2
If you bothered to read the stuff Martin posted, you would have gotten your answer. Basically, you need something that can be evaluated as an integer. Enumeration assigns an integer value to each name.
15th Mar 2018, 10:40 PM
John Wells
John Wells - avatar
+ 1
I did read it. I was just wondering if it would work.
15th Mar 2018, 11:54 PM
TheAtom
TheAtom - avatar
- 1
yes it will work. you can use string in statements but you must always use ( "" )
17th Mar 2018, 3:08 PM
Nwadike Kenneth
Nwadike Kenneth - avatar