What data type will be better for a field that need the user to choose one from two or more options? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What data type will be better for a field that need the user to choose one from two or more options?

the scenario is like this, whether a car is for 'private' or 'business' usage. will it be better to use enum or string with switch/if to assign it?

15th May 2018, 11:00 AM
Ferdinand Rosmi
Ferdinand Rosmi - avatar
1 Answer
0
It will be more correct - according to programming agreements - to use an Enum, but you can also use String. With Enum, though, it will be shorter.
15th May 2018, 11:25 AM
Eldar Bakerman